python
11 lines · 1 tab
Dr. Elena Vasquez
Apr 2026
1 tab
from gensim.models import Word2Vec
sentences = [
['customer', 'refund', 'payment', 'issue'],
['login', 'authentication', 'password', 'reset'],
['delivery', 'shipment', 'tracking', 'delay'],
['refund', 'chargeback', 'billing', 'payment'],
]
model = Word2Vec(sentences=sentences, vector_size=100, window=5, min_count=1, workers=2, sg=1)
print(model.wv.most_similar('refund', topn=3))
1 file · python
Explain with highlit
Dense embeddings help when lexical overlap is weak but semantic similarity matters. I use them for retrieval prototypes, clustering, and feature enrichment when transformer infrastructure is overkill. The main discipline is keeping training data clean and checking nearest neighbors for obvious failure modes.
Related snips
python
from transformers import AutoModelForSequenceClassification, AutoTokenizer, pipeline
model_name = 'distilbert-base-uncased-finetuned-sst-2-english'
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
Using Hugging Face transformers for modern NLP inference
hugging-face
transformers
nlp
by Dr. Elena Vasquez
1 tab
python
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.linear_model import LogisticRegression
from sklearn.pipeline import Pipeline
from sklearn.metrics import classification_report
pipeline = Pipeline([
Text vectorization with TF-IDF for strong classical baselines
tf-idf
nlp
text-classification
by Dr. Elena Vasquez
1 tab
python
import spacy
from spacy.matcher import Matcher
nlp = spacy.load('en_core_web_sm')
matcher = Matcher(nlp.vocab)
matcher.add('INCIDENT_ID', [[{'TEXT': {'REGEX': '^INC-[0-9]{6}$'}}]])
Natural language processing with spaCy pipelines and custom rules
spacy
nlp
entity-extraction
by Dr. Elena Vasquez
1 tab
python
import numpy as np
embeddings = np.array([
[0.9, 0.1, 0.2],
[0.1, 0.8, 0.3],
[0.7, 0.2, 0.4],
Linear algebra patterns for similarity and projection tasks
numpy
linear-algebra
embeddings
by Dr. Elena Vasquez
1 tab
Share this code
Here's the card — post it anywhere.