File size: 5,963 Bytes
c507515
90ef8e1
c507515
1a62ef2
c507515
 
 
 
 
 
1a62ef2
c507515
30cad76
 
 
 
 
 
5fdc3bf
 
5d18c0a
5fdc3bf
 
 
 
 
 
503a097
 
f062968
5fdc3bf
f062968
5f0a194
c9f9ceb
f062968
c507515
 
b60e5d6
c507515
 
 
 
 
 
 
 
 
 
47c0cfa
c507515
 
 
 
7356321
c507515
8f396cb
a954f40
8f396cb
c507515
3e83023
 
7356321
 
 
 
c507515
69822e4
c507515
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
---
license: mit
datasets:
- Locutusque/InstructMix
language:
- en
metrics:
- bleu
- perplexity
- loss
- accuracy
pipeline_tag: text-generation
widget:
  - text: >-
      <|USER|> Design a Neo4j database and Cypher function snippet to Display
      Extreme Dental hygiene: Using Mouthwash for Analysis for Beginners.
      Implement if/else or switch/case statements to handle different conditions
      related to the Consent. Provide detailed comments explaining your control
      flow and the reasoning behind each decision. <|ASSISTANT|> 
  - text: >-
      <|USER|> Write me a story about a magical place. <|ASSISTANT|> 
  - text: >-
      <|USER|> Write me an essay about the life of George Washington <|ASSISTANT|> 
  - text: >-
      <|USER|> Solve the following equation 2x + 10 = 20 <|ASSISTANT|> 
  - text: >-
      <|USER|> Craft me a list of some nice places to visit around the world. <|ASSISTANT|> 
inference:
  parameters:
    temperature: 0.8
    do_sample: True
    top_p: 0.14
    top_k: 41
    max_new_tokens: 250
    repetition_penalty: 1.176
---
# Model Card

## Model Details
- Model Name: gpt2-xl-conversational
- Model Type: Language Modeling
- Task: Generating Conversational Responses
- Hardware: 1x Nvidia Titan V
- Description: This model is trained on a dataset of conversations between a user and an AI assistant, with the goal of generating a coherent and relevant response to the user's input. It uses the GPT-2 architecture, a state-of-the-art transformer-based language model that is capable of generating high-quality text with a wide range of styles and tones. The model is fine-tuned on the conversational data using maximum likelihood estimation, and is evaluated based on its ability to generate responses that are both grammatically correct and semantically relevant to the user's input.
## Intended Use
This model is intended to be used for generating conversational responses in a variety of contexts, such as chatbots, virtual assistants, and customer service applications. It is designed to provide natural and engaging responses to user input, with a focus on maintaining a consistent tone and style throughout the conversation. The model is suitable for use in both text-based and voice-based interfaces, and can be easily integrated into existing applications using the PyTorch and Transformers frameworks.

## Training Data
The model is trained on a large dataset of conversational data, consisting of interactions between users and an AI assistant. The data is preprocessed to remove any sensitive information and is formatted in a way that is suitable for training a language model. The training data is split into a training set and a validation set, with the training set used to update the model parameters and the validation set used to evaluate the model performance. The model was trained on 300,000 examples and achieved excellent metrics.
## Model Architecture
The model architecture used in this model is GPT-2, a transformer-based language model that is capable of generating high-quality text with a wide range of styles and tones. The GPT-2 architecture consists of a multi-layered decoder-only transformer, with self-attention mechanisms that allow the model to capture long-term dependencies and generate coherent text.

## Evaluation Metrics
The model is evaluated based on several metrics, including loss, reward, penalty, BLEU score, and perplexity. The loss metric is calculated during training and reflects the difference between the predicted output and the actual output. The reward metric is based on the number of correct words generated by the model, while the penalty metric penalizes the model for repeating words consecutively. The BLEU score measures the similarity between the generated text and the ground truth text, while the perplexity metric measures how well the model is able to predict the next word in a sequence. During training, the model achieved the following metrics:

- BLEU score: 52
- Accuracy: 53
- perplexity: 4.3

Evaluation metrics:
|  Task  |Version|Metric|Value|   |Stderr|
|--------|------:|------|----:|---|-----:|
|pubmedqa|      0|acc   |0.536|±  |0.0223|


## Limitations and Bias
This model is not suitable for all use cases due to its limited training time on a weak computer. As a result, it may produce irrelevant or nonsensical responses. For optimal performance, I recommend using a GPU with at least 16 GB of VRAM and downloading the model manually instead of using the Transformers library. Here's how you should deploy the model:

```python
import torch
from transformers import GPT2LMHeadModel, AutoTokenizer
tokenizer = AutoTokenizer.from_pretrained("Locutusque/gpt2-xl-conversational")
model = GPT2LMHeadModel.from_pretrained("Locutusque/gpt2-xl-conversational", torch_dtype=torch.float16)
model.resize_token_embeddings(len(tokenizer))
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
model.to(device, dtype=torch.float32)
def generate_text(model: SENTIAForCausalLM, tokenizer, prompt, max_length=256):
    prompt = f'<|USER|> {prompt} <|ASSISTANT|> '
    input_ids = tokenizer.encode(prompt, add_special_tokens=True, max_length=max_length, truncation=True, return_tensors="pt").to(device)
    output = model.generate(input_ids, do_sample=True, temperature=0.3, top_p=0.7, top_k=23, repetition_penalty=1.176, max_length=max_length, pad_token_id=tokenizer.pad_token_id, eos_token_id=tokenizer.eos_token_id)
    output_ids = tokenizer.decode(output[0], skip_special_tokens=False)
    return output_ids
# Loop to interact with the model
while True:
    prompt = input("Enter a prompt (or 'q' to quit): ")
    if prompt == "q":
        break
    output_text = generate_text(model, tokenizer, prompt, max_length=1022)
    print(output_text)


```
## Deploying and training the model
The model has been fine-tuned on a specific input format that goes like this ```"<|USER|> {user prompt} <|ASSISTANT|> {model prediction} ".```