This shows how the model converts text into numbers (vectors).
1from sentence_transformers import SentenceTransformer
2
3# Load the model
4model = SentenceTransformer('anuragwagh0/hinglish-minilm')
5
6# Encode sentences
7sentences = ["Mujhe loan chahiye", "I want a loan"]
8embeddings = model.encode(sentences)
9
10print(embeddings.shape)
11# Output: (2, 384) -> Two sentences, each is a vector of size 384
This is how you use the model to "route" user queries to the right function in your app.
1from sentence_transformers import SentenceTransformer, util
2
3model = SentenceTransformer('anuragwagh0/hinglish-minilm')
4
5# 1. Define your App's Capabilities (The "Targets")
6app_actions = [
7 "Check Account Balance",
8 "Transfer Money",
9 "Call Customer Support"
10]
11
12# 2. Encode your actions (Do this once on startup)
13action_vectors = model.encode(app_actions)
14
15# 3. Simulate a User Query
16user_query = "Bhai paise bhejne the" # Hinglish Input
17query_vector = model.encode(user_query)
18
19# 4. Find the best match
20scores = util.cos_sim(query_vector, action_vectors)[0]
21best_match_idx = scores.argmax()
22best_action = app_actions[best_match_idx]
23
24print(f"User said: '{user_query}'")
25print(f"Bot Action: {best_action}")
26# Output: Bot Action: Transfer Money