File size: 4,850 Bytes
9e486be
 
 
 
 
 
e6a0448
 
 
9e486be
 
b89e29d
9e486be
d8c436e
 
 
 
 
9e486be
 
b89e29d
9e486be
 
b89e29d
9e486be
66ae84f
9e486be
b89e29d
309db04
b89e29d
309db04
b89e29d
309db04
b89e29d
309db04
b89e29d
309db04
66ae84f
9e486be
309db04
b89e29d
9e486be
b89e29d
 
 
9e486be
b89e29d
9e486be
 
 
 
b89e29d
9e486be
 
 
 
b89e29d
9e486be
 
 
 
b89e29d
9e486be
 
 
 
d8c436e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b89e29d
9e486be
 
 
d8c436e
9e486be
 
 
 
 
 
 
 
 
 
 
309db04
d8c436e
309db04
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50a5adc
d8c436e
50a5adc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b89e29d
9e486be
 
b89e29d
9e486be
 
 
 
b89e29d
9e486be
66ae84f
9e486be
 
b89e29d
9e486be
 
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
---
license: other
language:
- en
library_name: transformers
pipeline_tag: conversational
tags:
- llama
- decapoda-research-13b-hf
---

## Model Card for Model ID

Fine-tuned decapoda-research/llama-13b-hf on conversations

This repository contains a LLaMA-13B fine-tuned model.

⚠️ **I used [LLaMA-13B-hf](https://huggingface.co/decapoda-research/llama-13b-hf) as a base model, so this model is for Research purpose only (See the [license](https://huggingface.co/decapoda-research/llama-13b-hf/blob/main/LICENSE))**


## Model Details


### Model Description

The decapoda-research/llama-13b-hf model was finetuned on conversations and question answering prompts

**Developed by:** [More Information Needed]

**Shared by:** [More Information Needed]

**Model type:** Causal LM

**Language(s) (NLP):** English, multilingual

**License:** Research

**Finetuned from model:** decapoda-research/llama-13b-hf


## Model Sources [optional]

**Repository:** [More Information Needed]
**Paper:** [More Information Needed]
**Demo:** [More Information Needed]

## Uses

The model can be used for prompt answering


### Direct Use

The model can be used for prompt answering


### Downstream Use

Generating text and prompt answering


## Recommendations

Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.


# Usage

## Creating prompt

The model was trained on the following kind of prompt:

```python
def generate_prompt(instruction: str, input_ctxt: str = None) -> str:
    if input_ctxt:
        return f"""Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.

### Instruction:
{instruction}

### Input:
{input_ctxt}

### Response:"""
    else:
        return f"""Below is an instruction that describes a task. Write a response that appropriately completes the request.

### Instruction:
{instruction}

### Response:"""
```

## How to Get Started with the Model

Use the code below to get started with the model.

```python
from transformers import LlamaTokenizer, LlamaForCausalLM
from peft import PeftModel

MODEL_NAME = "decapoda-research/llama-13b-hf"
tokenizer = LlamaTokenizer.from_pretrained(MODEL_NAME, add_eos_token=True)
tokenizer.pad_token_id = 0

model = LlamaForCausalLM.from_pretrained(MODEL_NAME, load_in_8bit=True, device_map="auto")
model = PeftModel.from_pretrained(model, "Sandiago21/public-ai-model")
```

### Example of Usage
```python
from transformers import GenerationConfig

PROMPT = """Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.\n\n### Instruction:\nWhich is the capital city of Greece and with which countries does Greece border?\n\n### Input:\nQuestion answering\n\n### Response:\n"""
DEVICE = "cuda"

inputs = tokenizer(
    PROMPT,
    return_tensors="pt",
)

input_ids = inputs["input_ids"].to(DEVICE)

generation_config = GenerationConfig(
    temperature=0.1,
    top_p=0.95,
    repetition_penalty=1.2,
)

print("Generating Response ... ")
generation_output = model.generate(
    input_ids=input_ids,
    generation_config=generation_config,
    return_dict_in_generate=True,
    output_scores=True,
    max_new_tokens=256,
)

for s in generation_output.sequences:
    print(tokenizer.decode(s))
```

### Example Output
```python
Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.

### Instruction:
Which is the capital city of Greece and with which countries does Greece border?

### Input:
Question answering

### Response:

 
Generating...
<unk> Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.

### Instruction:
Which is the capital city of Greece and with which countries does Greece border?

### Input:
Question answering

### Response:
<unk>capital city of Athens and it borders Albania to the northwest, North Macedonia and Bulgaria to the northeast, Turkey to the east, and Libya to the southeast across the Mediterranean Sea.
```

## Training Details


### Training Data

The decapoda-research/llama-13b-hf was finetuned on conversations and question answering data


### Training Procedure

The decapoda-research/llama-13b-hf model was further trained and finetuned on question answering and prompts data for 1 epoch (approximately 10 hours of training on a single GPU)


## Model Architecture and Objective

The model is based on decapoda-research/llama-13b-hf model and finetuned adapters on top of the main model on conversations and question answering data.