Instructions to use psabharwal/trustai with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use psabharwal/trustai with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="psabharwal/trustai")# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("psabharwal/trustai", dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use psabharwal/trustai with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "psabharwal/trustai" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "psabharwal/trustai", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/psabharwal/trustai
- SGLang
How to use psabharwal/trustai with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "psabharwal/trustai" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "psabharwal/trustai", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "psabharwal/trustai" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "psabharwal/trustai", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use psabharwal/trustai with Docker Model Runner:
docker model run hf.co/psabharwal/trustai
TrustyAI Detoxify Causal Language Model
Model Description
The TrustyAI Detoxify Causal Language Model is a fine-tuned version of the OPT-350m model, specifically adapted to reduce toxicity in generated text. This model is designed to handle harmful language by identifying and replacing or neutralizing toxic phrases in real-time, making it suitable for applications like social media moderation, customer support, and more.
Intended Use
This model is intended for use in scenarios where toxic or harmful language is a concern. Some potential use cases include:
- Social Media Moderation: Automatically detecting and neutralizing toxic comments in posts or messages.
- Customer Support: Ensuring responses generated by AI-powered customer support tools are polite and non-offensive.
- Online Gaming: Monitoring and filtering player communication to maintain a positive environment.
- Community Management: Assisting moderators in identifying and managing toxic behavior in online communities.
Training Data
The model was fine-tuned on a curated dataset designed to reflect various forms of toxic language, including hate speech, insults, and other harmful content. The dataset was preprocessed to balance positive, neutral, and negative examples, ensuring the model learned to neutralize toxicity effectively without compromising the original context of the input text.
Training Procedure
The model was fine-tuned using the Supervised Fine-Tuning (SFT) methodology, following the guidelines provided by RedHat's TrustyAI project. Key steps included:
- Model: Based on
opt-350m_CASUAL_LM. - Dataset: Preprocessed and balanced for toxicity.
- Hyperparameters:
- Learning rate: 2e-5
- Batch size: 32
- Number of epochs: 3
- Optimization: AdamW
- Tools: Hugging Face Transformers, PyTorch, RedHat's TrustyAI framework.
Evaluation Metrics
The model was evaluated using the following metrics:
- Accuracy: Measures how often the model correctly identifies and neutralizes toxic phrases.
- F1-score: Balances precision and recall, providing a holistic view of the model's performance.
- Precision: The proportion of identified toxic phrases that were indeed toxic.
- Recall: The proportion of actual toxic phrases that the model correctly identified.
Limitations
While this model performs well in many scenarios, it has some limitations:
- Context Sensitivity: The model might struggle with complex contexts where the meaning of a phrase depends heavily on surrounding text.
- Edge Cases: Certain types of subtle or context-dependent toxicity may not be adequately neutralized.
- Bias: Despite efforts to balance the dataset, some biases may still exist, affecting model performance in underrepresented scenarios.
Ethical Considerations
Given the sensitive nature of toxic language, ethical considerations are paramount. This model is designed to assist in reducing harm, but users should be aware that:
- False Positives/Negatives: The model might incorrectly flag non-toxic language as toxic or miss actual toxic content.
- Fairness: Continuous monitoring and updates are recommended to address any biases that may emerge over time.
Model Versions
- Version 1.0: Initial release with base fine-tuning on toxic language dataset.
License
This model is licensed under the Apache 2.0 License.
How to Use
To use this model with Hugging Face Transformers, you can load it as follows:
from transformers import AutoModelForCausalLM, AutoTokenizer
model_name = "psabharwal/trustai"
model = AutoModelForCausalLM.from_pretrained(model_name)
tokenizer = AutoTokenizer.from_pretrained(model_name)
input_text = "You are a worthless piece of junk."
inputs = tokenizer(input_text, return_tensors="pt")
outputs = model.generate(**inputs)
generated_text = tokenizer.decode(outputs[0])
print(generated_text)
Model tree for psabharwal/trustai
Base model
facebook/opt-350m