File size: 5,862 Bytes
9378dcc
f0cffd2
7b38588
 
 
 
 
5d490d5
207fcd8
 
f0cffd2
 
 
 
 
 
 
 
 
 
3bfb3d7
f0cffd2
 
 
 
 
 
 
 
0424a04
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f0cffd2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
207fcd8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7b4a9b9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f0cffd2
 
8c13143
 
 
f0cffd2
 
 
7b38588
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
---
library_name: transformers
license: mit
language:
- en
- vi
pipeline_tag: text-generation
base_model: HuggingFaceH4/zephyr-7b-beta
tags:
- ghost
---

# Model Card for Model ID

**Ghost 7B Alpha, flying, v0.7.0**

## Model Details

### Model Description

This model is fine tuned from **HuggingFaceH4/zephyr-7b-beta** on a small synthetic datasets (about 200MB) for 50% English and 50% Vietnamese.

- **Developed by:** **Lam H**
- **Language(s) (NLP):** English, Vietnamese
- **License:** MIT
- **Finetuned from model:** [HuggingFaceH4/zephyr-7b-beta](https://huggingface.co/HuggingFaceH4/zephyr-7b-beta)

## Uses

This model supports both conversation chat and tasks. Feel free to experiment and don't limit your creativity.

The simplest way to try it is to use the `pipeline` from `transformers`.

```python
import torch
from transformers import pipeline

pipe = pipeline(
    "text-generation",
    model="lamhieu/ghost-7b-v0.9.0",
    torch_dtype=torch.bfloat16,
)
```

You can then try any of the sample codes below, formatted using the chat template.

```python
messages = [
    {"role": "system", "content": "You are a helpful assistant."},
    {"role": "user", "content": "nói tôi biết bệnh dịch hạch ở châu Âu do khuẩn nào gây ra"},
]
prompt = pipe.tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
tokenized = pipe.tokenizer(prompt, return_tensors="pt", add_special_tokens=False)
outputs = pipe.model.generate(**tokenized, max_new_tokens=512)
results = tokenizer.batch_decode(outputs)[0]
print(results)
# Bệnh dịch hạch ở châu Âu do khuẩn gây ra là do khuẩn Yersinia pestis.
```

```python
messages = [
    {"role": "system", "content": "You are a helpful assistant."},
    {"role": "user", "content": "Thông tin về Peristernia despecta"},
]
prompt = pipe.tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
tokenized = pipe.tokenizer(prompt, return_tensors="pt", add_special_tokens=False)
outputs = pipe.model.generate(**tokenized, max_new_tokens=512)
results = tokenizer.batch_decode(outputs)[0]
print(results)
# Peristernia despecta là một loài ốc biển, là động vật thân mềm chân bụng sống ở biển trong họ Fasciolariidae.
# ...
```

```python
messages = [
    {"role": "system", "content": "You are a helpful assistant."},
    {"role": "user", "content": "do u know vietnam ?"},
]
prompt = pipe.tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
tokenized = pipe.tokenizer(prompt, return_tensors="pt", add_special_tokens=False)
outputs = pipe.model.generate(**tokenized, max_new_tokens=512)
results = tokenizer.batch_decode(outputs)[0]
print(results)
# Yes, I have knowledge about Vietnam. Vietnam is a country in Southeast Asia, bordered by China to the north, Laos and Cambodia to the west, and the South China Sea to the east and south. Its capital city is Hanoi, and its largest city is Ho Chi Minh City (formerly known as Saigon). Vietnam has a population of approximately 100 million people and a diverse cultural heritage influenced by both Chinese and French colonialism. The country has a rich history, including periods of independence, colonization, and resistance, and has experienced significant economic growth in recent years.
```

```python
messages = [
    {"role": "system", "content": "You are a helpful assistant, who always provide explanation. Think like you are answering to a five year old."},
    {"role": "user", "content": "Tôi yêu em nhiều hơn em nghĩ.\n\nWhich language is this?"},
]
prompt = pipe.tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
tokenized = pipe.tokenizer(prompt, return_tensors="pt", add_special_tokens=False)
outputs = pipe.model.generate(**tokenized, max_new_tokens=512)
results = tokenizer.batch_decode(outputs)[0]
print(results)
# This is Vietnamese language. Vietnamese is a language spoken mainly in Vietnam and by the Vietnamese diaspora in many other countries. The sentence you provided means "I love you more than you think." It's like you have more love for someone than they realize.
```

Another example of what you can use to chat multiple turns.

```python
messages = [
    # {"role": "system", "content": "You are a helpful and knowledgeable assistant. You like to help and always give honest information, in its original language. In communication, you are always respectful, equal and promote positive behavior."},
    {"role": "system", "content": "You are a helpful assistant."}, # Describe to your assistant, anything.
    {"role": "user", "content": "Bla bla bla"},
    {"role": "assistant", "content": "Bla bla bla"},
    {"role": "user", "content": "Bla bla bla"},
]
prompt = pipe.tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
tokenized = pipe.tokenizer(prompt, return_tensors="pt", add_special_tokens=False)
outputs = pipe.model.generate(**tokenized, max_new_tokens=512)
results = tokenizer.batch_decode(outputs)[0]
print(results)
```

## Evaluation

### Results

#### OpenLLM Leaderboard

It will be evaluated and updated later.

#### VMLU

Below are the results evaluated with the VMLU evaluation suite, which is often used to evaluate models that work with Vietnamese.
Note: the results are run with the model in 4bit quantum form, I'm not sure if it has any loss in results or not, if someone can help me run it with full it would be great.

![VMLU - lamhieu/ghost-7b-v0.9.0](/static-proxy?url=https%3A%2F%2Fcdn-uploads.huggingface.co%2Fproduction%2Fuploads%2F600ae38cc92b79f54efd4556%2FGdMgr0-YnAGRqD_RJr_ux.png%3C%2Fspan%3E)

## More Information

Many thanks for
- Datasets: [5CD-AI](https://huggingface.co/5CD-AI), [vilm](https://huggingface.co/vilm).
- Library: [unsloth](https://github.com/unslothai/unsloth)

## Model Card Contact

**Lam H** ([email protected])