Views
No views yet
anchor: Conversation text or agent descriptionpositive: Similar/relevant text to the anchornegative: Dissimilar/irrelevant text to the anchor1from sentence_transformers import SentenceTransformer
2
3# Load the model
4model = SentenceTransformer('msugimura/gatekeeper_agent_responding')
5
6# Example: Agent routing for conversation
7conversation = "I've been feeling anxious and need help with stress management"
8agent_descriptions = [
9 "Licensed therapist specializing in anxiety and stress management",
10 "Fitness trainer who creates workout routines for stress relief",
11 "Financial advisor who helps with investment planning"
12]
13
14# Get embeddings
15conversation_embedding = model.encode(conversation)
16agent_embeddings = model.encode(agent_descriptions)
17
18# Calculate similarities
19from sentence_transformers.util import cos_sim
20similarities = cos_sim(conversation_embedding, agent_embeddings)
21
22print("Similarity scores:", similarities)
23# Expected: Highest similarity with the therapist1import requests
2
3# Example API call to Portcullis service
4response = requests.post("http://localhost:8000/should_agents_respond", json={
5 "conversation": "I've been feeling anxious and need help",
6 "agent_descriptions": [
7 "Licensed therapist specializing in anxiety treatment",
8 "Fitness trainer for workout routines",
9 "Financial advisor for investments"
10 ],
11 "threshold": 0.4
12})
13
14result = response.json()
15print("Qualified agents:", result["qualified_agents"])SentenceTransformer(
(0): Transformer({'max_seq_length': 256, 'do_lower_case': False}) with Transformer model: BertModel
(1): Pooling({'word_embedding_dimension': 384, 'pooling_mode_cls_token': False, 'pooling_mode_mean_tokens': True, 'pooling_mode_max_tokens': False, 'pooling_mode_mean_sqrt_len_tokens': False})
(2): Normalize()
)1@misc{gatekeeper_agent_responding_2024,
2 title={Gatekeeper Agent Responding Model},
3 author={Michael Sugimura},
4 year={2024},
5 publisher={Hugging Face},
6 url={https://huggingface.co/msugimura/gatekeeper_agent_responding}
7}