How do you cluster / retrieve code snippets?
hardAnswer
- (1) Code-specific embeddings: CodeBERT, StarCoder, GTE-code, OpenAI text-embedding-3 handle code decently.
- (2) Combine with AST features / API signatures.
- (3) Cluster with HDBSCAN or embed + LSH for near-duplicate detection (deduplicate training data of code models).
- (4) Retrieval-augmented: embed function bodies, retrieve similar for autocomplete.
- Standard in GitHub Copilot's underlying retrieval, code deduplication for training.
Check yourself — multiple choice
- Same as text
- CodeBERT / StarCoder / GTE-code embeddings (+ AST features) → HDBSCAN cluster or LSH near-duplicate; used in Copilot retrieval + training data dedup
- Random
- Not possible
Code embeddings: CodeBERT/StarCoder; used in Copilot retrieval + dedup.
#applications#nlp
Practise Unsupervised Learning
214 interview questions in this topic.
Related questions
- BM25 — why is it still competitive with modern retrievers?
- Vector search / approximate nearest neighbors — main algorithms.
- How is RAG retrieval an unsupervised problem?
- Applications of clustering in NLP.
- Interview: users complain search returns irrelevant results — how do you fix?
- Interview: choose a sentence embedding model for a startup RAG.