Embedding Model
Sharc-Embed
SHARC’s embedding model is optimized for code:| Property | Value |
|---|---|
| Model | Sharc-Embed |
| Dimensions | 4096 |
| Max Tokens | 8192 |
Key Features
- Code-optimized: Trained on large code corpora
- High dimensionality: 4096 dims capture nuanced semantics
- Long context: 8K tokens handles large functions
Embedding Generation
Process Overview
Batching Strategy
Embeddings are generated in batches for efficiency:- Batch size: Up to 200 texts per request
- Parallel processing: Multiple batches processed concurrently
- Processing 2000 chunks: ~3-5 seconds total
Vector Storage
Full Dimensions
Unlike some implementations that truncate embeddings, SHARC stores the full 4096 dimensions:Normalization
Vectors are L2-normalized for cosine similarity:Context Injection
Embeddings capture more than raw code. SHARC injects context:For Code (AST-parsed)
- This is a method in
AuthService - It’s in the
authmodule - File is
services/auth.ts
With Decorators
For Documentation
Semantic Properties
What Embeddings Capture
| Property | Example |
|---|---|
| Function purpose | ”authentication” vs “validation” |
| Code patterns | async/await, error handling |
| Data structures | arrays, objects, classes |
| Domain concepts | ”user”, “payment”, “order” |
| Relationships | caller-callee, inheritance |
Similarity Examples
Performance Metrics
| Metric | Value |
|---|---|
| Latency (200 texts) | ~500ms |
| Throughput | ~2000 texts/second |
| Batch efficiency | 10x vs single requests |
| Memory per embedding | 16KB (4096 x 4 bytes) |
Troubleshooting
Slow Embedding Generation
- Re-index the codebase if search results look stale.
- Ensure your codebase indexing completed successfully.
- Retry with a more specific semantic query.