Instructions to use maxmarcon/gpt2-medium-sarcasm-defuser with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use maxmarcon/gpt2-medium-sarcasm-defuser with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="maxmarcon/gpt2-medium-sarcasm-defuser")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("maxmarcon/gpt2-medium-sarcasm-defuser") model = AutoModelForCausalLM.from_pretrained("maxmarcon/gpt2-medium-sarcasm-defuser", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use maxmarcon/gpt2-medium-sarcasm-defuser with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "maxmarcon/gpt2-medium-sarcasm-defuser" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "maxmarcon/gpt2-medium-sarcasm-defuser", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/maxmarcon/gpt2-medium-sarcasm-defuser
- SGLang
How to use maxmarcon/gpt2-medium-sarcasm-defuser 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 "maxmarcon/gpt2-medium-sarcasm-defuser" \ --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": "maxmarcon/gpt2-medium-sarcasm-defuser", "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 "maxmarcon/gpt2-medium-sarcasm-defuser" \ --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": "maxmarcon/gpt2-medium-sarcasm-defuser", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use maxmarcon/gpt2-medium-sarcasm-defuser with Docker Model Runner:
docker model run hf.co/maxmarcon/gpt2-medium-sarcasm-defuser
# Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("maxmarcon/gpt2-medium-sarcasm-defuser")
model = AutoModelForCausalLM.from_pretrained("maxmarcon/gpt2-medium-sarcasm-defuser", device_map="auto")GP2 Sarcasm Defuser
Description
GPT-2 model (medium 0.4B parameters) fine-tuned to defues sarcasm. Example:
Prompt: So glad investment bankers and hedge funds make so much on the low wages these guys get.<|BOS|>
Generated after prompt: It's concerning that investment bankers and hedge funds are making so much on the low wages these workers receive.
(The model use the special <|BOS|> token as a marker for where the generated, defuse comment should start).
Training and Evaluation
The model has been trained on ~4500 sarcastic comments from the Sarcasm on Reddit Kaggle dataset. The dataset includes a selection of comments from Reddit that were marked as sarcastic by the author of the comment. Another ~500 comments have been used to test the trained model's performance.
In order to teach the model what a defused, not sarcastic comment looks like, we used a more powerful LLM to generate defused comments for the Kaggle dataset. We used the gemma-3-12b-it model with 12B parameters and we queried via the Google API with the following prompt for each comment:
given this sarcastic comment: <SARCASTIC_COMMENT>,
which is a response to this other comment: <CONTEXT>,
remove all the sarcasm from it while keeping the original meaning. Don't output anything else, and don't try to describe the comment in the third person",
where <SARCASTIC_COMMENT> is the sarcastic comment from the Kaggle dataset and <CONTEXT> is the comment that preceded the sarcstic comment (this comment was also
available as part of the Kaggle dataset). This gives the LLM additional information on how to "translate" the sarcastic comment into a "normal" one.
How to use
Coming soon
- Downloads last month
- 13
Evaluation results
- similarity:mean on customkaggle0.669
- similarity:std on customkaggle0.153
- similarity:min on customkaggle0.234
- similarity:max on customkaggle1.000
- similarity:q1 on customkaggle0.561
- similarity:q2 on customkaggle0.677
- similarity:q3 on customkaggle0.783
- sarcasm_prob_orig:mean on customkaggle0.110
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="maxmarcon/gpt2-medium-sarcasm-defuser")