Layasaran commited on
Commit
1f752f3
·
verified ·
1 Parent(s): 8b90eb3

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +90 -1
README.md CHANGED
@@ -1,3 +1,92 @@
1
  ---
2
- license: mit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ pipeline_tag: sentence-similarity
3
+ tags:
4
+ - sentence-transformers
5
+ - feature-extraction
6
+ - sentence-similarity
7
+ - RAG
8
+ - domain-adapted
9
+ - custom-embeddings
10
+ language:
11
+ - en
12
+ library_name: sentence-transformers
13
+ license: apache-2.0
14
+ metrics:
15
+ - cosine_similarity
16
+ - mrr
17
+ - ndcg@10
18
  ---
19
+
20
+ # Custom Contextual Embedding Model (v1.0-FineTuned)
21
+
22
+ This is a specialized, fine-tuned dense text embedding model engineered for production Retrieval-Augmented Generation (RAG), context-aware semantic search, and document reranking.
23
+
24
+ This model has undergone custom contrastive instruction tuning to improve cross-domain query-to-document matching and handling of nuanced contextual semantics.
25
+
26
+ ---
27
+
28
+ ## Key Improvements & Features
29
+
30
+ * **Custom Contrastive Fine-Tuning:** Trained using Multiple Negatives Ranking Loss (MNRL) paired with hard-negative mining for high-precision retrieval.
31
+ * **Enhanced Context Window:** Retains structural context for long-form passages (up to 512–8192 tokens depending on sequence truncation limits).
32
+ * **Low-Latency Retrieval:** 0.6B parameter scale balances embedding quality with fast query-side inference on standard GPU infrastructure.
33
+ * **Optimized Cosine Space:** Specifically calibrated for Cosine Similarity metric evaluation, eliminating the need for expensive vector recalibration.
34
+
35
+ ---
36
+
37
+ ## Usage (Sentence-Transformers)
38
+
39
+ Using this model becomes easy when you have [`sentence-transformers`](https://www.SBERT.net) installed:
40
+
41
+ ```bash
42
+ pip install -U sentence-transformers
43
+
44
+ from sentence_transformers import SentenceTransformer, util
45
+
46
+ model = SentenceTransformer(
47
+ "Layasaran/text_embed_0.5b",
48
+ trust_remote_code=True
49
+ )
50
+
51
+ texts = [
52
+ "Scientists explore the universe driven by curiosity.",
53
+ "Children learn through curious exploration.",
54
+ "Historical discoveries began with curious questions.",
55
+ "Animals use curiosity to adapt and survive.",
56
+ "Philosophy examines the nature of curiosity.",
57
+ ]
58
+
59
+ doc_embeddings = model.encode(texts, convert_to_tensor=True)
60
+
61
+ query = "How do children acquire knowledge?"
62
+ query_embedding = model.encode(query, convert_to_tensor=True)
63
+
64
+ similarity_scores = util.cos_sim(query_embedding, doc_embeddings)[0]
65
+
66
+ top_k = 3
67
+ top_indices = similarity_scores.argsort(descending=True)[:top_k]
68
+
69
+ print(f"Query: '{query}'\n")
70
+ print("Top Retrieved Contexts for RAG Prompt:")
71
+ print("-" * 50)
72
+
73
+ retrieved_context = []
74
+ for idx in top_indices:
75
+ score = float(similarity_scores[idx])
76
+ text = texts[idx]
77
+ retrieved_context.append(text)
78
+ print(f"Score: {score:.4f} | Text: {text}")
79
+
80
+ rag_context_str = "\n".join([f"- {doc}" for doc in retrieved_context])
81
+ rag_prompt = f"""Use the following context to answer the question:
82
+
83
+ Context:
84
+ {rag_context_str}
85
+
86
+ Question: {query}
87
+ Answer:"""
88
+
89
+ print("\n" + "=" * 50)
90
+ print("Final RAG Prompt structure:")
91
+ print("=" * 50)
92
+ print(rag_prompt)