Skip to content

Commit 169eabe

Browse files
Refactor example scripts to remove redundant model type specifications
- Updated multiple documentation files to streamline the model initialization by removing the explicit model type (WhichModel) from the EmbeddingModel.from_pretrained_hf method calls. - This change improves code clarity and maintains consistency across the guides.
1 parent b8bc2f2 commit 169eabe

5 files changed

Lines changed: 3 additions & 18 deletions

File tree

README.md

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,6 @@ import embed_anything
138138

139139
# Load a custom BERT model from Hugging Face
140140
model = EmbeddingModel.from_pretrained_hf(
141-
WhichModel.Bert,
142141
model_id="sentence-transformers/all-MiniLM-L12-v2"
143142
)
144143

@@ -187,7 +186,6 @@ import embed_anything
187186

188187
# Load a SPLADE model for sparse embeddings
189188
model = EmbeddingModel.from_pretrained_hf(
190-
WhichModel.SparseBert,
191189
model_id="prithivida/Splade_PP_en_v1"
192190
)
193191

@@ -427,7 +425,6 @@ model = EmbeddingModel.from_pretrained_hf(
427425
# Semantic encoder for determining chunk boundaries
428426
# This model analyzes text to find natural semantic breaks
429427
semantic_encoder = EmbeddingModel.from_pretrained_hf(
430-
WhichModel.Jina,
431428
model_id="jinaai/jina-embeddings-v2-small-en"
432429
)
433430

@@ -457,7 +454,6 @@ from embed_anything import EmbeddingModel, WhichModel, TextEmbedConfig, EmbedDat
457454

458455
# Load your embedding model
459456
model = EmbeddingModel.from_pretrained_hf(
460-
WhichModel.Bert,
461457
model_id="sentence-transformers/all-MiniLM-L12-v2"
462458
)
463459

@@ -542,8 +538,7 @@ from embed_anything import EmbeddingModel, WhichModel, TextEmbedConfig
542538
import embed_anything
543539

544540
# Load model
545-
model = EmbeddingModel.from_pretrained_local(
546-
WhichModel.Jina,
541+
model = EmbeddingModel.from_pretrained_hf(
547542
model_id="jinaai/jina-embeddings-v2-small-en"
548543
)
549544

@@ -576,8 +571,7 @@ import embed_anything
576571
import numpy as np
577572

578573
# Load model
579-
model = EmbeddingModel.from_pretrained_local(
580-
WhichModel.Bert,
574+
model = EmbeddingModel.from_pretrained_hf(
581575
model_id="sentence-transformers/all-MiniLM-L12-v2"
582576
)
583577

@@ -598,8 +592,7 @@ from embed_anything import EmbeddingModel, WhichModel, TextEmbedConfig
598592
import embed_anything
599593

600594
# Load model
601-
model = EmbeddingModel.from_pretrained_local(
602-
WhichModel.Bert,
595+
model = EmbeddingModel.from_pretrained_hf(
603596
model_id="sentence-transformers/all-MiniLM-L12-v2"
604597
)
605598

docs/guides/Qwen.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import numpy as np
1717

1818
# Initialize Qwen3 embedding model
1919
model = EmbeddingModel.from_pretrained_hf(
20-
WhichModel.Qwen3,
2120
model_id="Qwen/Qwen3-Embedding-0.6B",
2221
dtype=Dtype.F32 # Use float32 for best quality, F16 for faster inference
2322
)

docs/guides/adapters.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ es_adapter.create_index(
4141

4242
# Load embedding model
4343
model = EmbeddingModel.from_pretrained_hf(
44-
WhichModel.Bert,
4544
model_id="sentence-transformers/all-MiniLM-L12-v2"
4645
)
4746

docs/guides/images.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ from embed_anything import EmbeddingModel, WhichModel
1818

1919
# Load CLIP model for image-text embeddings
2020
model = EmbeddingModel.from_pretrained_hf(
21-
WhichModel.Clip,
2221
model_id="openai/clip-vit-base-patch16"
2322
)
2423

@@ -52,7 +51,6 @@ from embed_anything import EmbeddingModel, WhichModel
5251

5352
# Load model
5453
model = EmbeddingModel.from_pretrained_hf(
55-
WhichModel.Clip,
5654
model_id="openai/clip-vit-base-patch16"
5755
)
5856

@@ -104,7 +102,6 @@ from embed_anything import EmbeddingModel, WhichModel
104102

105103
# Load model
106104
model = EmbeddingModel.from_pretrained_hf(
107-
WhichModel.Clip,
108105
model_id="openai/clip-vit-base-patch16"
109106
)
110107

docs/guides/semantic.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,12 @@ import embed_anything
2323

2424
# Main embedding model - generates final embeddings
2525
model = EmbeddingModel.from_pretrained_hf(
26-
WhichModel.Bert,
2726
model_id="sentence-transformers/all-MiniLM-L12-v2"
2827
)
2928

3029
# Semantic encoder - determines where to split text
3130
# This model analyzes text to find natural semantic breaks
3231
semantic_encoder = EmbeddingModel.from_pretrained_hf(
33-
WhichModel.Jina,
3432
model_id="jinaai/jina-embeddings-v2-small-en"
3533
)
3634

@@ -68,7 +66,6 @@ import embed_anything
6866

6967
# Use a more powerful semantic encoder for better boundary detection
7068
semantic_encoder = EmbeddingModel.from_pretrained_hf(
71-
WhichModel.Jina,
7269
model_id="jinaai/jina-embeddings-v2-base-en" # Larger model for better analysis
7370
)
7471

0 commit comments

Comments
 (0)