Sentence Similarity
sentence-transformers
Safetensors
PEFT
English
text-embeddings
retrieval
web-search
news
Instructions to use desearch/Desearch-Embedding-8B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- sentence-transformers
How to use desearch/Desearch-Embedding-8B with sentence-transformers:
from sentence_transformers import SentenceTransformer model = SentenceTransformer("desearch/Desearch-Embedding-8B") sentences = [ "That is a happy person", "That is a happy dog", "That is a very happy person", "Today is a sunny day" ] embeddings = model.encode(sentences) similarities = model.similarity(embeddings, embeddings) print(similarities.shape) # [4, 4] - PEFT
How to use desearch/Desearch-Embedding-8B with PEFT:
Task type is invalid.
- Notebooks
- Google Colab
- Kaggle
Use news questions in the usage examples
Browse files
README.md
CHANGED
|
@@ -61,10 +61,13 @@ from sentence_transformers import SentenceTransformer
|
|
| 61 |
|
| 62 |
model = SentenceTransformer("desearch/Desearch-Embedding-8B")
|
| 63 |
|
| 64 |
-
queries = [
|
|
|
|
|
|
|
|
|
|
| 65 |
documents = [
|
| 66 |
-
"
|
| 67 |
-
"
|
| 68 |
]
|
| 69 |
|
| 70 |
query_embeddings = model.encode(queries, prompt_name="query")
|
|
@@ -83,10 +86,14 @@ from peft import PeftModel
|
|
| 83 |
from transformers import AutoModel, AutoTokenizer
|
| 84 |
|
| 85 |
task = "Given a web search query, retrieve relevant passages that answer the query"
|
| 86 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 87 |
documents = [
|
| 88 |
-
"
|
| 89 |
-
"
|
| 90 |
]
|
| 91 |
|
| 92 |
tokenizer = AutoTokenizer.from_pretrained("desearch/Desearch-Embedding-8B", padding_side="left")
|
|
|
|
| 61 |
|
| 62 |
model = SentenceTransformer("desearch/Desearch-Embedding-8B")
|
| 63 |
|
| 64 |
+
queries = [
|
| 65 |
+
"Who became Apple’s chief executive and will lead the Sept. 9, 2026 “Surprise and Shine” product event?",
|
| 66 |
+
"How much does the base Mac Mini M6 cost in US dollars as of its August 2026 announcement?",
|
| 67 |
+
]
|
| 68 |
documents = [
|
| 69 |
+
"John Ternus, Apple's new chief executive, takes the stage at the September 9, 2026 “Surprise and Shine” event to unveil the latest iPhones and Apple Watches.",
|
| 70 |
+
"Apple surprised buyers in late August 2026 with the Mac Mini M6 at $899 and the Mac Mini M5 Pro at $1,699, both shipping on September 22.",
|
| 71 |
]
|
| 72 |
|
| 73 |
query_embeddings = model.encode(queries, prompt_name="query")
|
|
|
|
| 86 |
from transformers import AutoModel, AutoTokenizer
|
| 87 |
|
| 88 |
task = "Given a web search query, retrieve relevant passages that answer the query"
|
| 89 |
+
questions = [
|
| 90 |
+
"Who became Apple’s chief executive and will lead the Sept. 9, 2026 “Surprise and Shine” product event?",
|
| 91 |
+
"How much does the base Mac Mini M6 cost in US dollars as of its August 2026 announcement?",
|
| 92 |
+
]
|
| 93 |
+
queries = [f"Instruct: {task}\nQuery:{q}" for q in questions]
|
| 94 |
documents = [
|
| 95 |
+
"John Ternus, Apple's new chief executive, takes the stage at the September 9, 2026 “Surprise and Shine” event to unveil the latest iPhones and Apple Watches.",
|
| 96 |
+
"Apple surprised buyers in late August 2026 with the Mac Mini M6 at $899 and the Mac Mini M5 Pro at $1,699, both shipping on September 22.",
|
| 97 |
]
|
| 98 |
|
| 99 |
tokenizer = AutoTokenizer.from_pretrained("desearch/Desearch-Embedding-8B", padding_side="left")
|