Instructions to use AIMH/mental-xlnet-base-cased with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use AIMH/mental-xlnet-base-cased with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="AIMH/mental-xlnet-base-cased")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("AIMH/mental-xlnet-base-cased") model = AutoModelForCausalLM.from_pretrained("AIMH/mental-xlnet-base-cased") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use AIMH/mental-xlnet-base-cased with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "AIMH/mental-xlnet-base-cased" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "AIMH/mental-xlnet-base-cased", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/AIMH/mental-xlnet-base-cased
- SGLang
How to use AIMH/mental-xlnet-base-cased 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 "AIMH/mental-xlnet-base-cased" \ --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": "AIMH/mental-xlnet-base-cased", "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 "AIMH/mental-xlnet-base-cased" \ --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": "AIMH/mental-xlnet-base-cased", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use AIMH/mental-xlnet-base-cased with Docker Model Runner:
docker model run hf.co/AIMH/mental-xlnet-base-cased
This model is pretrained from the checkpoint of xlnet-base-cased for the mental healthcare domain. XLNet model pre-trained on English language. It was introduced in the paper XLNet: Generalized Autoregressive Pretraining for Language Understanding by Yang et al. and first released in this repository.
Usage
Here is how to use this model to get the features of a given text in PyTorch:
from transformers import XLNetTokenizer, XLNetModel
tokenizer = XLNetTokenizer.from_pretrained('AIMH/mental-xlnet-base-cased')
model = XLNetModel.from_pretrained('AIMH/mental-xlnet-base-cased')
inputs = tokenizer("Hello, my dog is cute", return_tensors="pt")
outputs = model(**inputs)
last_hidden_states = outputs.last_hidden_state
To minimize the influence of worrying mask predictions, this model is gated. To download a gated model, you’ll need to be authenticated. Know more about gated models.
This model is biased due to training with posts about self-reported mental conditions and should not be used for text generation application, e.g., chatbot for mental health counseling.
Paper
@article{ji-domain-specific,
author = {Shaoxiong Ji and Tianlin Zhang and Kailai Yang and Sophia Ananiadou and Erik Cambria and J{\"o}rg Tiedemann},
journal = {arXiv preprint arXiv:2304.10447},
title = {Domain-specific Continued Pretraining of Language Models for Capturing Long Context in Mental Health},
year = {2023},
url = {https://arxiv.org/abs/2304.10447}
}
Disclaimer
The model predictions are not psychiatric diagnoses. We recommend anyone who suffers from mental health issues to call the local mental health helpline and seek professional help if possible.
- Downloads last month
- -