Sriram-Gov commited on
Commit
461ec2a
1 Parent(s): 2b60d74

Update README.md

Browse files

detailed description added

Files changed (1) hide show
  1. README.md +115 -1
README.md CHANGED
@@ -1,3 +1,117 @@
1
  ---
2
- license: mit
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ license: llama2
3
+ datasets: https://github.com/SriRamGovardhanam/Sarcastic-Headline-Llama2/blob/main/formatted_headline_data.csv
4
  ---
5
+
6
+ # Fine tuning Llama 2 by a generated dataset to respond sarcastically
7
+
8
+ The main idea behind the model is to add behaviour to an LLM so that for a given input(news headline) the model responds back with output(sarcastic_headline) in a funny,
9
+ sarcastic way.<br>
10
+ All the existing open datasets available related to sarcasm are either extracted from social media like twitter or reddit which were mostly replies to parent post or
11
+ just a labelled dataset which have sarcastic, non-sarcastic sentences. we are looking for dataset which has normal sentence and corresponding sarcastic version for the model to understand.
12
+ We can generate such dataset using a LLM by giving a random sentence and ask the model to generate sarcastic version of it.
13
+ Once we get the generated dataset, we can fine tune a LLM model and to give sarcastic response.
14
+
15
+ ## Model Details
16
+
17
+ We are using Llama 2 13B version to generate the sarcastic sentence by using an appropriate prompt template, for the input sentences we are referring to a news headline category
18
+ dataset. once we generate dataset, we format the dataset and do PEFT on pretrained Llama 2 7B weights. The fine tuned model can behave sarcastically and generate satirical responses.
19
+ To ensure the quality and diversity of the training data, we are picking news headline category dataset so that we can cover multiple different random sentences without worrying
20
+ about grammatic mistakes in input sentence.
21
+
22
+
23
+ - **Sorce Dataset:** https://www.kaggle.com/datasets/rmisra/news-category-dataset
24
+ - **Dataset after ETL:** https://github.com/SriRamGovardhanam/Sarcastic-Headline-Llama2/blob/main/formatted_headline_data.csv
25
+ - **Model type:** LLM
26
+ - **Finetuned from model:** Llama2 7B https://huggingface.co/TinyPixel/Llama-2-7B-bf16-sharded/tree/main
27
+
28
+ ### Model Fine tuning code
29
+ Huggingface team developed a python library autotrain-advanced with which we can fine tune any LLM with just one line of code.
30
+ You can find python code to generate the data, to fine tune the model in below repo
31
+
32
+ - **Repository:** https://github.com/SriRamGovardhanam/Sarcastic-Headline-Llama2
33
+ - **For code line by line breakdown refer:** [Coming soon]
34
+
35
+ ## Uses
36
+ - **Enhanced Natural Language Understanding:** In applications like chatbots or virtual assistants, a model trained to understand
37
+ sarcasm can provide more contextually relevant responses, improving user interactions.
38
+ - **Niche applications:** For some websites like TheOnion, we may able to support/improve writers ability. Social media platforms to engage users with witty and sarcastic responses.
39
+
40
+ ### Direct Use
41
+
42
+ Refer to the Inference code available in repo: https://github.com/SriRamGovardhanam/Sarcastic-Headline-Llama2
43
+
44
+
45
+ ### Downstream Use
46
+ - **Content Generation:** In creative writing and content creation, the model can be used to inject humor and sarcasm into articles, scripts, advertisements, or marketing materials to make them more engaging.
47
+ - **Brand Persona:** Some companies adopt a brand persona characterized by humor and sarcasm in their communications. The model can assist in maintaining this tone in marketing campaigns and customer interactions.
48
+ - **Social Media Engagement:** Brands and influencers on social media may use the model to craft sarcastic posts or responses that resonate with their audience, leading to increased engagement and brand awareness.
49
+
50
+ ### Recommendations
51
+ - There is a lot of room for improvement here. At ETL level, at the time of generating dataset, we can provide different prompts for different categories available to generate
52
+ even better funny responses.
53
+ - Dataset used here to fine tune have only 2100 examples, we can increase dataset size. At the time of fine tuning, because of GPU memory constraints, I have only performed
54
+ 8 epochs - this can be increased.
55
+ - I opted for news headline because of quality and diversity of the training data. If sole purpose of the model is more focussed on generating more enticing sarcastic news headline, then another
56
+ better approach here would be generating news description 1st and generate headline for the description.
57
+
58
+ ## How to Get Started with the Model
59
+ - For Fine tuning your own dataset, you can use the colab notebook files in this repo: https://github.com/SriRamGovardhanam/Sarcastic-Headline-Llama2
60
+ - For a doing a quick inference on this model card, refer to Inference notebook in the same repo.
61
+
62
+
63
+ ## Training Details
64
+ ```
65
+ autotrain llm --train --project_name 'sarcastic-headline-gen' --model TinyPixel/Llama-2-7B-bf16-sharded \
66
+ --data_path '/content/sarcastic-headline' \
67
+ --use_peft \
68
+ --use_int4 \
69
+ --learning_rate 2e-4 \
70
+ --train_batch_size 8 \
71
+ --num_train_epochs 8 \
72
+ --trainer sft \
73
+ --model_max_length 340 > training.log &
74
+ ```
75
+
76
+ ### Training Data
77
+ ![image/png](https://cdn-uploads.huggingface.co/production/uploads/64f247058be22790b9cff971/l5FASl8ZWtFD4OctriGbN.png)
78
+
79
+
80
+ ### Results
81
+ Input headline: **mansoons are best for mosquitoes**
82
+ <br>Input Formatted Template to the fine tuned LLM:
83
+ ```
84
+ You are a savage, disrespectful and witty agent. You convert below news headline into a funny, humiliating, creatively sarcastic news headline while still maintaining the original context.
85
+ ### headline: mansoons are best for mosquitoes
86
+ ### sarcastic_headline:
87
+ ```
88
+ <br>Output after Inferencing:
89
+ ```
90
+ You are a savage, disrespectful and witty agent. You convert below news headline into a funny, humiliating, creatively sarcastic news headline while still maintaining the original context.
91
+ ### headline: mansoons are best for mosquitoes
92
+ ### sarcastic_headline: Another Study Proves That Men's Sweaty Bums Are The Best Repellent Against Mosquitoes
93
+ ```
94
+
95
+ #### Summary
96
+ - The primary purpose of this model is often to generate humor and entertainment. It can be used in chatbots, virtual assistants, or social media platforms to engage users with witty and sarcastic responses.
97
+ - One advantage of using Llama2 model instead of chat GPT for dataset generation is, OpenAI will not allow offensive words/ hate speech as rules for a model, even if we
98
+ include them in prompt template, chatGPT will not produce brutal/ humiliating responses which is reasonable and ethical for such a big organization.
99
+ - This advatange is a double edged sword, as some people cannot handle these type of responses and may consider them as harrasement/ offensive.
100
+
101
+ ### Model Objective
102
+ This model is not intended to target specific race, gender, region etc., Sole purpose of this model is to understand LLM's and tap the LLM's ability to entertain, engage.
103
+
104
+ ### Compute Infrastructure
105
+ Google colab pro is needed if you are planning to tune more than 5 epochs for a 2100 samples of model_max_length < 650.
106
+
107
+
108
+ ## Citation
109
+ The source dataset - news headlines are taken from https://www.kaggle.com/datasets/rmisra/news-category-dataset <br>
110
+ Misra, Rishabh. "News Category Dataset." arXiv preprint arXiv:2209.11429 (2022).
111
+
112
+ ## Model Card Authors
113
+ Sriram Govardhanam <br>
114
+ http://www.linkedin.com/in/SriRamGovardhanam
115
+
116
+ ## Model Card Contact
117