Views
No views yet
1pip install torch sentencepiece scikit-learn matplotlib
2git lfs install
3git clone https://huggingface.co/convaiinnovations/hindi-embedding-foundational-model
4cd hindi-embedding-foundational-modelpip install unsloth transformers bitsandbytes accelerate langchain langchain-community faiss-cpupython hindi-rag-system.py --model_dir /path/to/your/model --tokenizer_dir /path/to/tokenizer --data_dir ./data --output_dir ./output --indexpython hindi-rag-system.py --model_dir /path/to/your/model --tokenizer_dir /path/to/tokenizer --output_dir ./output --interactive --qa1from hindi_embeddings import HindiEmbedder
2# Initialize the embedder
3model = HindiEmbedder("path/to/hindi-embedding-foundational-model")
4# Encode sentences to embeddings
5sentences = [
6 "मुझे हिंदी भाषा बहुत पसंद है।",
7 "मैं हिंदी भाषा सीख रहा हूँ।"
8]
9embeddings = model.encode(sentences)
10print(f"Embedding shape: {embeddings.shape}")
11# Compute similarity between sentences
12similarity = model.compute_similarity(sentences[0], sentences[1])
13print(f"Similarity: {similarity:.4f}")
14# Perform semantic search
15query = "भारत की राजधानी"
16documents = [
17 "दिल्ली भारत की राजधानी है।",
18 "मुंबई भारत का सबसे बड़ा शहर है।",
19 "हिमालय पर्वत भारत के उत्तर में स्थित है।"
20]
21results = model.search(query, documents)
22for i, result in enumerate(results):
23 print(f"{i+1}. Score: {result['score']:.4f}")
24 print(f" Document: {result['document']}")
25# Visualize embeddings
26example_sentences = [
27 "मुझे हिंदी में पढ़ना बहुत पसंद है।",
28 "आज मौसम बहुत अच्छा है।",
29 "भारत एक विशाल देश है।"
30]
31model.visualize_embeddings(example_sentences)