Sentence Similarity
sentence-transformers
TensorBoard
Safetensors
Transformers
English
bert
feature-extraction
agent-routing
conversation-matching
text-embeddings-inference
Run this model with HF Jobs
Run msugimura/gatekeeper_agent_responding on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs to fine-tune https://huggingface.co/msugimura/gatekeeper_agent_responding. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/msugimura/gatekeeper_agent_responding on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Instructions to use msugimura/gatekeeper_agent_responding with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- sentence-transformers
How to use msugimura/gatekeeper_agent_responding with sentence-transformers:
from sentence_transformers import SentenceTransformer model = SentenceTransformer("msugimura/gatekeeper_agent_responding") sentences = [ "That is a happy person", "That is a happy dog", "That is a very happy person", "Today is a sunny day" ] embeddings = model.encode(sentences) similarities = model.similarity(embeddings, embeddings) print(similarities.shape) # [4, 4] - Transformers
How to use msugimura/gatekeeper_agent_responding with Transformers:
# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModel tokenizer = AutoTokenizer.from_pretrained("msugimura/gatekeeper_agent_responding") model = AutoModel.from_pretrained("msugimura/gatekeeper_agent_responding", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Upload README.md
Browse files123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149---pipeline_tag: sentence-similaritytags:- sentence-transformers- feature-extraction- sentence-similarity- transformers- agent-routing- conversation-matchinglanguage: enlicense: apache-2.0datasets:- custommetrics:- cosine_similaritybase_model: sentence-transformers/all-MiniLM-L12-v2---
# Gatekeeper Agent Responding Model
This is a fine-tuned [sentence-transformers](https://www.SBERT.net) model based on **all-MiniLM-L12-v2** that has been specifically trained for **agent routing and conversation matching**. The model determines whether agents should respond to conversations based on semantic similarity.
## Model Details
### Base Model- **Base Model**: [sentence-transformers/all-MiniLM-L12-v2](https://huggingface.co/sentence-transformers/all-MiniLM-L12-v2)- **Model Architecture**: MiniLM-L12 (Microsoft)- **Embedding Dimensions**: 384- **Max Sequence Length**: 256 tokens
### Training DataThe model was fine-tuned on two custom datasets using triplet training:- **semantic_triplet_training_data_round1.pkl**: 469 samples- **inverse_semantic_triplet_training_data.pkl**: 475 samples
Each sample contains:- `anchor`: Conversation text or agent description- `positive`: Similar/relevant text to the anchor- `negative`: Dissimilar/irrelevant text to the anchor
### Training Configuration- **Loss Function**: MultipleNegativesRankingLoss- **Batch Size**: 16- **Learning Rate**: 2e-5- **Epochs**: 1- **Warmup Ratio**: 0.1- **Training Framework**: sentence-transformers v2.7.0+
### PerformanceEvaluation results on held-out test sets:- **Semantic Triplets Accuracy**: 97.87%- **Inverse Semantic Triplets Accuracy**: 100.00%
## Usage
### Direct Usage (Sentence Transformers)```pythonfrom sentence_transformers import SentenceTransformer
# Load the modelmodel = SentenceTransformer('msugimura/gatekeeper_agent_responding')
# Example: Agent routing for conversationconversation = "I've been feeling anxious and need help with stress management"agent_descriptions = [ "Licensed therapist specializing in anxiety and stress management", "Fitness trainer who creates workout routines for stress relief", "Financial advisor who helps with investment planning"]
# Get embeddingsconversation_embedding = model.encode(conversation)agent_embeddings = model.encode(agent_descriptions)
# Calculate similaritiesfrom sentence_transformers.util import cos_simsimilarities = cos_sim(conversation_embedding, agent_embeddings)
print("Similarity scores:", similarities)# Expected: Highest similarity with the therapist```
### API Usage (Portcullis Service)```pythonimport requests
# Example API call to Portcullis serviceresponse = requests.post("http://localhost:8000/should_agents_respond", json={ "conversation": "I've been feeling anxious and need help", "agent_descriptions": [ "Licensed therapist specializing in anxiety treatment", "Fitness trainer for workout routines", "Financial advisor for investments" ], "threshold": 0.4})
result = response.json()print("Qualified agents:", result["qualified_agents"])```
## Intended Use Cases
1. **Agent Routing**: Automatically route conversations to appropriate specialist agents2. **Conversation Matching**: Match user queries with relevant service providers3. **Semantic Search**: Find similar conversations or agent descriptions4. **Content Recommendation**: Recommend agents based on conversation context
## Limitations
- **Domain Specific**: Optimized for agent-conversation matching scenarios- **English Only**: Trained primarily on English text- **Context Length**: Limited to 256 tokens per input- **Training Data**: Performance depends on similarity to training domain
## Technical Details
### Model Architecture```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())```
### Training Process1. **Data Preprocessing**: Cleaned triplet datasets, removed extraneous columns2. **Multi-Dataset Training**: Combined training on both semantic and inverse semantic data3. **Loss Function**: MultipleNegativesRankingLoss with in-batch negatives4. **Evaluation**: TripletEvaluator on held-out validation sets
## Citation
If you use this model, please cite:
```bibtex@misc{gatekeeper_agent_responding_2024, title={Gatekeeper Agent Responding Model}, author={Michael Sugimura}, year={2024}, publisher={Hugging Face}, url={https://huggingface.co/msugimura/gatekeeper_agent_responding}}```
## Contact
For questions or issues, please contact [your-email] or open an issue in the model repository.README.mdAdded+149