This is a specialized, fine-tuned dense text embedding model engineered for production Retrieval-Augmented Generation (RAG), context-aware semantic search, and document reranking.
This model has undergone custom contrastive instruction tuning to improve cross-domain query-to-document matching and handling of nuanced contextual semantics.
Using this model becomes easy when you have
sentence-transformers installed:
1pip install -U sentence-transformers
2
3from sentence_transformers import SentenceTransformer, util
4
5model = SentenceTransformer(
6 "Layasaran/text_embed_0.5b",
7 trust_remote_code=True
8)
9
10texts = [
11 "Scientists explore the universe driven by curiosity.",
12 "Children learn through curious exploration.",
13 "Historical discoveries began with curious questions.",
14 "Animals use curiosity to adapt and survive.",
15 "Philosophy examines the nature of curiosity.",
16]
17
18doc_embeddings = model.encode(texts, convert_to_tensor=True)
19
20query = "How do children acquire knowledge?"
21query_embedding = model.encode(query, convert_to_tensor=True)
22
23similarity_scores = util.cos_sim(query_embedding, doc_embeddings)[0]
24
25top_k = 3
26top_indices = similarity_scores.argsort(descending=True)[:top_k]
27
28print(f"Query: '{query}'\n")
29print("Top Retrieved Contexts for RAG Prompt:")
30print("-" * 50)
31
32retrieved_context = []
33for idx in top_indices:
34 score = float(similarity_scores[idx])
35 text = texts[idx]
36 retrieved_context.append(text)
37 print(f"Score: {score:.4f} | Text: {text}")
38
39rag_context_str = "\n".join([f"- {doc}" for doc in retrieved_context])
40rag_prompt = f"""Use the following context to answer the question:
41
42Context:
43{rag_context_str}
44
45Question: {query}
46Answer:"""
47
48print("\n" + "=" * 50)
49print("Final RAG Prompt structure:")
50print("=" * 50)
51print(rag_prompt)