初始化项目,由ModelHub XC社区提供模型
Model: vutuka/Llama-3.1-8B-african-aya Source: Original Platform
This commit is contained in:
43
.gitattributes
vendored
Normal file
43
.gitattributes
vendored
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
*.7z filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.arrow filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.bin filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.ftz filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.gz filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.h5 filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.joblib filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.model filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.npy filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.npz filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.onnx filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.ot filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.parquet filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.pb filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.pickle filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.pkl filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.pt filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.pth filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.rar filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
||||||
|
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.tar filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.tflite filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.tgz filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.wasm filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.xz filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.zip filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.zst filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
||||||
|
unsloth.F16.gguf filter=lfs diff=lfs merge=lfs -text
|
||||||
|
unsloth.Q4_K_M.gguf filter=lfs diff=lfs merge=lfs -text
|
||||||
|
unsloth.Q8_0.gguf filter=lfs diff=lfs merge=lfs -text
|
||||||
|
unsloth.Q5_K_M.gguf filter=lfs diff=lfs merge=lfs -text
|
||||||
|
llama-3.1-8B-african-aya.Q4_K_M.gguf filter=lfs diff=lfs merge=lfs -text
|
||||||
|
llama-3.1-8B-african-aya.F16.gguf filter=lfs diff=lfs merge=lfs -text
|
||||||
|
llama-3.1-8B-african-aya.Q5_K_M.gguf filter=lfs diff=lfs merge=lfs -text
|
||||||
|
llama-3.1-8B-african-aya.Q8_0.gguf filter=lfs diff=lfs merge=lfs -text
|
||||||
169
README.md
Normal file
169
README.md
Normal file
@@ -0,0 +1,169 @@
|
|||||||
|
---
|
||||||
|
base_model: unsloth/meta-llama-3.1-8b-bnb-4bit
|
||||||
|
language:
|
||||||
|
- en
|
||||||
|
- yo
|
||||||
|
- zu
|
||||||
|
- xh
|
||||||
|
- wo
|
||||||
|
- fr
|
||||||
|
- ig
|
||||||
|
- ha
|
||||||
|
- am
|
||||||
|
- ar
|
||||||
|
- so
|
||||||
|
- sw
|
||||||
|
- sn
|
||||||
|
license: apache-2.0
|
||||||
|
tags:
|
||||||
|
- text-generation-inference
|
||||||
|
- transformers
|
||||||
|
- unsloth
|
||||||
|
- llama
|
||||||
|
- trl
|
||||||
|
datasets:
|
||||||
|
- vutuka/aya_african_alpaca
|
||||||
|
pipeline_tag: text-generation
|
||||||
|
---
|
||||||
|
|
||||||
|
# Llama-3.1-8B-african-aya
|
||||||
|
|
||||||
|
- **Developed by:** vutuka
|
||||||
|
- **License:** apache-2.0
|
||||||
|
- **Finetuned from model :** unsloth/meta-llama-3.1-8b-bnb-4bit
|
||||||
|
|
||||||
|
This llama model was trained 2x faster with [Unsloth](https://github.com/unslothai/unsloth) and Huggingface's TRL library.
|
||||||
|
|
||||||
|
## Unsloth Inference (2x Faaaaster)
|
||||||
|
|
||||||
|
```sh
|
||||||
|
%%capture
|
||||||
|
# Installs Unsloth, Xformers (Flash Attention) and all other packages!
|
||||||
|
!pip install "unsloth[colab-new] @ git+https://github.com/unslothai/unsloth.git"
|
||||||
|
!pip install --no-deps "xformers<0.0.27" "trl<0.9.0" peft accelerate bitsandbytes
|
||||||
|
```
|
||||||
|
|
||||||
|
```py
|
||||||
|
max_seq_length = 4096
|
||||||
|
dtype = None
|
||||||
|
load_in_4bit = True # Use 4bit quantization to reduce memory usage.
|
||||||
|
|
||||||
|
alpaca_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.
|
||||||
|
|
||||||
|
### Instruction:
|
||||||
|
{}
|
||||||
|
|
||||||
|
### Input:
|
||||||
|
{}
|
||||||
|
|
||||||
|
### Response:
|
||||||
|
{}"""
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
```py
|
||||||
|
## Load the Quantize model
|
||||||
|
from unsloth import FastLanguageModel
|
||||||
|
model, tokenizer = FastLanguageModel.from_pretrained(
|
||||||
|
model_name = "vutuka/Llama-3.1-8B-african-aya",
|
||||||
|
max_seq_length = max_seq_length,
|
||||||
|
dtype = dtype,
|
||||||
|
load_in_4bit = load_in_4bit,
|
||||||
|
)
|
||||||
|
FastLanguageModel.for_inference(model)
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
```py
|
||||||
|
|
||||||
|
def llama_african_aya(input: str = "", instruction: str = ""):
|
||||||
|
inputs = tokenizer(
|
||||||
|
[
|
||||||
|
alpaca_prompt.format(
|
||||||
|
instruction,
|
||||||
|
input,
|
||||||
|
"",
|
||||||
|
)
|
||||||
|
], return_tensors = "pt").to("cuda")
|
||||||
|
text_streamer = TextStreamer(tokenizer)
|
||||||
|
# _ = model.generate(**inputs, streamer = text_streamer, max_new_tokens = 800)
|
||||||
|
# Generate the response
|
||||||
|
output = model.generate(**inputs, max_new_tokens=1024)
|
||||||
|
|
||||||
|
# Decode the generated response
|
||||||
|
generated_text = tokenizer.decode(output[0], skip_special_tokens=True)
|
||||||
|
|
||||||
|
# Extract the response part if needed (assuming the response starts after "### Response:")
|
||||||
|
response_start = generated_text.find("### Response:") + len("### Response:")
|
||||||
|
response = generated_text[response_start:].strip()
|
||||||
|
|
||||||
|
# Format the response in Markdown
|
||||||
|
# markdown_response = f"{response}"
|
||||||
|
|
||||||
|
# Render the markdown response
|
||||||
|
# display(Markdown(markdown_response))
|
||||||
|
return response
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
```py
|
||||||
|
llama_african_aya(
|
||||||
|
instruction="",
|
||||||
|
input="Àwọn ajínigbé méjì ni wọ́n mú ní Supare Akoko, ṣàlàyé ìtàn náà."
|
||||||
|
)
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## LlamaCPP Code
|
||||||
|
|
||||||
|
```sh
|
||||||
|
CMAKE_ARGS="-DGGML_BLAS=ON -DGGML_BLAS_VENDOR=OpenBLAS" \
|
||||||
|
pip install llama-cpp-python
|
||||||
|
````
|
||||||
|
|
||||||
|
```py
|
||||||
|
from huggingface_hub import hf_hub_download
|
||||||
|
from llama_cpp import Llama
|
||||||
|
|
||||||
|
## Download the GGUF model
|
||||||
|
model_name = "vutuka/Llama-3.1-8B-african-aya"
|
||||||
|
model_file = "llama-3.1-8B-african-aya.Q8_0.gguf"
|
||||||
|
model_path = hf_hub_download(model_name, filename=model_file)
|
||||||
|
|
||||||
|
## Instantiate model from downloaded file
|
||||||
|
llm = Llama(
|
||||||
|
model_path=model_path,
|
||||||
|
n_ctx=4096,
|
||||||
|
n_gpu_layers=-1,
|
||||||
|
n_batch=512,
|
||||||
|
verbose=False,
|
||||||
|
)
|
||||||
|
|
||||||
|
## Run inference
|
||||||
|
alpaca_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.
|
||||||
|
|
||||||
|
### Instruction:
|
||||||
|
{}
|
||||||
|
|
||||||
|
### Input:
|
||||||
|
{}
|
||||||
|
|
||||||
|
### Response:
|
||||||
|
{}"""
|
||||||
|
|
||||||
|
prompt = alpaca_prompt.format(
|
||||||
|
"",
|
||||||
|
"Àwọn ajínigbé méjì ni wọ́n mú ní Supare Akoko, ṣàlàyé ìtàn náà.",
|
||||||
|
"",
|
||||||
|
)
|
||||||
|
|
||||||
|
res = llm(prompt) # Res is a dictionary
|
||||||
|
|
||||||
|
## Unpack and the generated text from the LLM response dictionary and print it
|
||||||
|
print(res["choices"][0]["text"])
|
||||||
|
# res is short for result
|
||||||
|
```
|
||||||
|
|
||||||
|
[<img src="https://raw.githubusercontent.com/unslothai/unsloth/main/images/unsloth%20made%20with%20love.png" width="200"/>](https://github.com/unslothai/unsloth)
|
||||||
34
adapter_config.json
Normal file
34
adapter_config.json
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
{
|
||||||
|
"alpha_pattern": {},
|
||||||
|
"auto_mapping": null,
|
||||||
|
"base_model_name_or_path": "unsloth/meta-llama-3.1-8b-bnb-4bit",
|
||||||
|
"bias": "none",
|
||||||
|
"fan_in_fan_out": false,
|
||||||
|
"inference_mode": true,
|
||||||
|
"init_lora_weights": true,
|
||||||
|
"layer_replication": null,
|
||||||
|
"layers_pattern": null,
|
||||||
|
"layers_to_transform": null,
|
||||||
|
"loftq_config": {},
|
||||||
|
"lora_alpha": 16,
|
||||||
|
"lora_dropout": 0,
|
||||||
|
"megatron_config": null,
|
||||||
|
"megatron_core": "megatron.core",
|
||||||
|
"modules_to_save": null,
|
||||||
|
"peft_type": "LORA",
|
||||||
|
"r": 16,
|
||||||
|
"rank_pattern": {},
|
||||||
|
"revision": "unsloth",
|
||||||
|
"target_modules": [
|
||||||
|
"down_proj",
|
||||||
|
"v_proj",
|
||||||
|
"gate_proj",
|
||||||
|
"k_proj",
|
||||||
|
"q_proj",
|
||||||
|
"o_proj",
|
||||||
|
"up_proj"
|
||||||
|
],
|
||||||
|
"task_type": "CAUSAL_LM",
|
||||||
|
"use_dora": false,
|
||||||
|
"use_rslora": false
|
||||||
|
}
|
||||||
3
adapter_model.safetensors
Normal file
3
adapter_model.safetensors
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
version https://git-lfs.github.com/spec/v1
|
||||||
|
oid sha256:e08d0f35850fc49a699d21d29f7cd2648f4543afeb2ea192a677843c447e6c23
|
||||||
|
size 167832240
|
||||||
3
config.json
Normal file
3
config.json
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"model_type": "llama"
|
||||||
|
}
|
||||||
3
llama-3.1-8B-african-aya.F16.gguf
Normal file
3
llama-3.1-8B-african-aya.F16.gguf
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
version https://git-lfs.github.com/spec/v1
|
||||||
|
oid sha256:7399708cda37472136843f9e1b1c98c17d0831a8334ad4965c5443edd4dd5e27
|
||||||
|
size 16068890688
|
||||||
3
llama-3.1-8B-african-aya.Q4_K_M.gguf
Normal file
3
llama-3.1-8B-african-aya.Q4_K_M.gguf
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
version https://git-lfs.github.com/spec/v1
|
||||||
|
oid sha256:686deff213a7be355bfb950313717457e3dfaf29765cfcb0845d849cd71293d2
|
||||||
|
size 4920733760
|
||||||
3
llama-3.1-8B-african-aya.Q5_K_M.gguf
Normal file
3
llama-3.1-8B-african-aya.Q5_K_M.gguf
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
version https://git-lfs.github.com/spec/v1
|
||||||
|
oid sha256:18c251857783068a6677242ca94fef1a6085e0913a125f2f36c05e2d8131b5de
|
||||||
|
size 5732986944
|
||||||
3
llama-3.1-8B-african-aya.Q8_0.gguf
Normal file
3
llama-3.1-8B-african-aya.Q8_0.gguf
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
version https://git-lfs.github.com/spec/v1
|
||||||
|
oid sha256:dcd49bfe8ba451cb4e232d45484c92aab4c4d81d48d397803686d60fae2e8480
|
||||||
|
size 8540770368
|
||||||
23
special_tokens_map.json
Normal file
23
special_tokens_map.json
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
{
|
||||||
|
"bos_token": {
|
||||||
|
"content": "<|begin_of_text|>",
|
||||||
|
"lstrip": false,
|
||||||
|
"normalized": false,
|
||||||
|
"rstrip": false,
|
||||||
|
"single_word": false
|
||||||
|
},
|
||||||
|
"eos_token": {
|
||||||
|
"content": "<|end_of_text|>",
|
||||||
|
"lstrip": false,
|
||||||
|
"normalized": false,
|
||||||
|
"rstrip": false,
|
||||||
|
"single_word": false
|
||||||
|
},
|
||||||
|
"pad_token": {
|
||||||
|
"content": "<|finetune_right_pad_id|>",
|
||||||
|
"lstrip": false,
|
||||||
|
"normalized": false,
|
||||||
|
"rstrip": false,
|
||||||
|
"single_word": false
|
||||||
|
}
|
||||||
|
}
|
||||||
410563
tokenizer.json
Normal file
410563
tokenizer.json
Normal file
File diff suppressed because it is too large
Load Diff
2063
tokenizer_config.json
Normal file
2063
tokenizer_config.json
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user