初始化项目,由ModelHub XC社区提供模型
Model: PAIXAI/Astrid-1B-CPU Source: Original Platform
This commit is contained in:
35
.gitattributes
vendored
Normal file
35
.gitattributes
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
*.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
|
||||
199
README.md
Normal file
199
README.md
Normal file
@@ -0,0 +1,199 @@
|
||||
---
|
||||
language:
|
||||
- en
|
||||
library_name: transformers
|
||||
tags:
|
||||
- gpt
|
||||
- llm
|
||||
- large language model
|
||||
- PAIX.Cloud
|
||||
inference: true
|
||||
thumbnail: https://static.wixstatic.com/media/bdee4e_8aa5cefc86024bc88f7e20e3e19d9ff3~mv2.png/v1/fill/w_192%2Ch_192%2Clg_1%2Cusm_0.66_1.00_0.01/bdee4e_8aa5cefc86024bc88f7e20e3e19d9ff3~mv2.png
|
||||
---
|
||||
# Model Card
|
||||
## Summary
|
||||
|
||||
This model, Astrid-1B-CPU, is a GPT-NeoX model for causal language modeling, designed to generate human-like text.
|
||||
It's part of our mission to make AI technology accessible to everyone, focusing on personalization, data privacy, and transparent AI governance.
|
||||
Trained in English, it's a versatile tool for a variety of applications.
|
||||
This model is one of the many models available on our platform, and we currently have a 1B and 7B open-source model.
|
||||
|
||||
This model was trained by [PAIX.Cloud](https://www.paix.cloud/).
|
||||
- Wait list: [Wait List](https://www.paix.cloud/join-waitlist)
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
To use the model with the `transformers` library on a machine with GPUs, first make sure you have the `transformers`, `accelerate` and `torch` libraries installed.
|
||||
|
||||
```bash
|
||||
pip install transformers==4.30.1
|
||||
pip install accelerate==0.20.3
|
||||
pip install torch==2.0.0
|
||||
```
|
||||
|
||||
```python
|
||||
import torch
|
||||
from transformers import pipeline
|
||||
|
||||
generate_text = pipeline(
|
||||
model="PAIXAI/Astrid-1B-CPU",
|
||||
torch_dtype="auto",
|
||||
trust_remote_code=True,
|
||||
use_fast=True,
|
||||
device_map={"": "cuda:0"},
|
||||
)
|
||||
|
||||
res = generate_text(
|
||||
"Why is drinking water so healthy?",
|
||||
min_new_tokens=2,
|
||||
max_new_tokens=256,
|
||||
do_sample=False,
|
||||
num_beams=1,
|
||||
temperature=float(0.3),
|
||||
repetition_penalty=float(1.2),
|
||||
renormalize_logits=True
|
||||
)
|
||||
print(res[0]["generated_text"])
|
||||
```
|
||||
|
||||
You can print a sample prompt after the preprocessing step to see how it is feed to the tokenizer:
|
||||
|
||||
```python
|
||||
print(generate_text.preprocess("Why is drinking water so healthy?")["prompt_text"])
|
||||
```
|
||||
|
||||
```bash
|
||||
<|prompt|>Why is drinking water so healthy?<|endoftext|><|answer|>
|
||||
```
|
||||
|
||||
Alternatively, you can download [h2oai_pipeline.py](h2oai_pipeline.py), store it alongside your notebook, and construct the pipeline yourself from the loaded model and tokenizer. If the model and the tokenizer are fully supported in the `transformers` package, this will allow you to set `trust_remote_code=False`.
|
||||
|
||||
```python
|
||||
import torch
|
||||
from h2oai_pipeline import H2OTextGenerationPipeline
|
||||
from transformers import AutoModelForCausalLM, AutoTokenizer
|
||||
|
||||
tokenizer = AutoTokenizer.from_pretrained(
|
||||
"PAIXAI/Astrid-1B-CPU",
|
||||
use_fast=True,
|
||||
padding_side="left",
|
||||
trust_remote_code=True,
|
||||
)
|
||||
model = AutoModelForCausalLM.from_pretrained(
|
||||
"PAIXAI/Astrid-1B-CPU",
|
||||
torch_dtype="auto",
|
||||
device_map={"": "cuda:0"},
|
||||
trust_remote_code=True,
|
||||
)
|
||||
generate_text = H2OTextGenerationPipeline(model=model, tokenizer=tokenizer)
|
||||
|
||||
res = generate_text(
|
||||
"Why is drinking water so healthy?",
|
||||
min_new_tokens=2,
|
||||
max_new_tokens=256,
|
||||
do_sample=False,
|
||||
num_beams=1,
|
||||
temperature=float(0.3),
|
||||
repetition_penalty=float(1.2),
|
||||
renormalize_logits=True
|
||||
)
|
||||
print(res[0]["generated_text"])
|
||||
```
|
||||
|
||||
|
||||
You may also construct the pipeline from the loaded model and tokenizer yourself and consider the preprocessing steps:
|
||||
|
||||
```python
|
||||
from transformers import AutoModelForCausalLM, AutoTokenizer
|
||||
|
||||
model_name = "PAIXAI/Astrid-1B-CPU" # either local folder or huggingface model name
|
||||
# Important: The prompt needs to be in the same format the model was trained with.
|
||||
# You can find an example prompt in the experiment logs.
|
||||
prompt = "<|prompt|>How are you?<|endoftext|><|answer|>"
|
||||
|
||||
tokenizer = AutoTokenizer.from_pretrained(
|
||||
model_name,
|
||||
use_fast=True,
|
||||
trust_remote_code=True,
|
||||
)
|
||||
model = AutoModelForCausalLM.from_pretrained(
|
||||
model_name,
|
||||
torch_dtype="auto",
|
||||
device_map={"": "cuda:0"},
|
||||
trust_remote_code=True,
|
||||
)
|
||||
model.cuda().eval()
|
||||
inputs = tokenizer(prompt, return_tensors="pt", add_special_tokens=False).to("cuda")
|
||||
|
||||
# generate configuration can be modified to your needs
|
||||
tokens = model.generate(
|
||||
**inputs,
|
||||
min_new_tokens=2,
|
||||
max_new_tokens=256,
|
||||
do_sample=False,
|
||||
num_beams=1,
|
||||
temperature=float(0.3),
|
||||
repetition_penalty=float(1.2),
|
||||
renormalize_logits=True
|
||||
)[0]
|
||||
|
||||
tokens = tokens[inputs["input_ids"].shape[1]:]
|
||||
answer = tokenizer.decode(tokens, skip_special_tokens=True)
|
||||
print(answer)
|
||||
```
|
||||
|
||||
## Model Architecture
|
||||
|
||||
```
|
||||
GPTNeoXForCausalLM(
|
||||
(gpt_neox): GPTNeoXModel(
|
||||
(embed_in): Embedding(50304, 2048)
|
||||
(layers): ModuleList(
|
||||
(0-15): 16 x GPTNeoXLayer(
|
||||
(input_layernorm): LayerNorm((2048,), eps=1e-05, elementwise_affine=True)
|
||||
(post_attention_layernorm): LayerNorm((2048,), eps=1e-05, elementwise_affine=True)
|
||||
(attention): GPTNeoXAttention(
|
||||
(rotary_emb): RotaryEmbedding()
|
||||
(query_key_value): Linear(in_features=2048, out_features=6144, bias=True)
|
||||
(dense): Linear(in_features=2048, out_features=2048, bias=True)
|
||||
)
|
||||
(mlp): GPTNeoXMLP(
|
||||
(dense_h_to_4h): Linear(in_features=2048, out_features=8192, bias=True)
|
||||
(dense_4h_to_h): Linear(in_features=8192, out_features=2048, bias=True)
|
||||
(act): GELUActivation()
|
||||
)
|
||||
)
|
||||
)
|
||||
(final_layer_norm): LayerNorm((2048,), eps=1e-05, elementwise_affine=True)
|
||||
)
|
||||
(embed_out): Linear(in_features=2048, out_features=50304, bias=False)
|
||||
)
|
||||
```
|
||||
|
||||
## Model Configuration
|
||||
|
||||
This model was trained using H2O LLM Studio and with the configuration in [cfg.yaml](cfg.yaml). Visit [H2O LLM Studio](https://github.com/h2oai/h2o-llmstudio) to learn how to train your own large language models.
|
||||
|
||||
|
||||
## Model Validation
|
||||
|
||||
Model validation results using [EleutherAI lm-evaluation-harness](https://github.com/EleutherAI/lm-evaluation-harness).
|
||||
|
||||
```bash
|
||||
CUDA_VISIBLE_DEVICES=0 python main.py --model hf-causal-experimental --model_args pretrained=PAIXAI/Astrid-1B-CPU --tasks openbookqa,arc_easy,winogrande,hellaswag,arc_challenge,piqa,boolq --device cuda &> eval.log
|
||||
```
|
||||
|
||||
|
||||
## Disclaimer
|
||||
|
||||
Please read this disclaimer carefully before using the large language model provided in this repository. Your use of the model signifies your agreement to the following terms and conditions.
|
||||
|
||||
- Biases and Offensiveness: The large language model is trained on a diverse range of internet text data, which may contain biased, racist, offensive, or otherwise inappropriate content. By using this model, you acknowledge and accept that the generated content may sometimes exhibit biases or produce content that is offensive or inappropriate. The developers of this repository do not endorse, support, or promote any such content or viewpoints.
|
||||
- Limitations: The large language model is an AI-based tool and not a human. It may produce incorrect, nonsensical, or irrelevant responses. It is the user's responsibility to critically evaluate the generated content and use it at their discretion.
|
||||
- Use at Your Own Risk: Users of this large language model must assume full responsibility for any consequences that may arise from their use of the tool. The developers and contributors of this repository shall not be held liable for any damages, losses, or harm resulting from the use or misuse of the provided model.
|
||||
- Ethical Considerations: Users are encouraged to use the large language model responsibly and ethically. By using this model, you agree not to use it for purposes that promote hate speech, discrimination, harassment, or any form of illegal or harmful activities.
|
||||
- Reporting Issues: If you encounter any biased, offensive, or otherwise inappropriate content generated by the large language model, please report it to the repository maintainers through the provided channels. Your feedback will help improve the model and mitigate potential issues.
|
||||
- Changes to this Disclaimer: The developers of this repository reserve the right to modify or update this disclaimer at any time without prior notice. It is the user's responsibility to periodically review the disclaimer to stay informed about any changes.
|
||||
|
||||
By using the large language model provided in this repository, you agree to accept and comply with the terms and conditions outlined in this disclaimer. If you do not agree with any part of this disclaimer, you should refrain from using the model and any content generated by it.
|
||||
112
cfg.yaml
Normal file
112
cfg.yaml
Normal file
@@ -0,0 +1,112 @@
|
||||
architecture:
|
||||
backbone_dtype: float16
|
||||
force_embedding_gradients: false
|
||||
gradient_checkpointing: true
|
||||
intermediate_dropout: 0.0
|
||||
pretrained: true
|
||||
pretrained_weights: ''
|
||||
augmentation:
|
||||
random_parent_probability: 0.0
|
||||
skip_parent_probability: 0.0
|
||||
token_mask_probability: 0.0
|
||||
dataset:
|
||||
add_eos_token_to_answer: true
|
||||
add_eos_token_to_prompt: true
|
||||
answer_column: output
|
||||
chatbot_author: PAIX.cloud
|
||||
chatbot_name: Astrid
|
||||
data_sample: 1.0
|
||||
data_sample_choice:
|
||||
- Train
|
||||
- Validation
|
||||
limit_chained_samples: false
|
||||
mask_prompt_labels: true
|
||||
parent_id_column: None
|
||||
personalize: true
|
||||
prompt_column:
|
||||
- instruction
|
||||
text_answer_separator: <|answer|>
|
||||
text_prompt_start: <|prompt|>
|
||||
train_dataframe: data/user/oasst/train_full.pq
|
||||
validation_dataframe: None
|
||||
validation_size: 0.01
|
||||
validation_strategy: automatic
|
||||
environment:
|
||||
compile_model: false
|
||||
find_unused_parameters: false
|
||||
gpus:
|
||||
- '0'
|
||||
huggingface_branch: main
|
||||
mixed_precision: true
|
||||
number_of_workers: 8
|
||||
seed: -1
|
||||
trust_remote_code: true
|
||||
use_fsdp: false
|
||||
experiment_name: Astrid-1B-1
|
||||
llm_backbone: EleutherAI/pythia-1b-deduped
|
||||
logging:
|
||||
logger: Neptune
|
||||
neptune_project: llmstudio
|
||||
number_of_texts: 10
|
||||
output_directory: output/user/Astrid-1B-1/
|
||||
prediction:
|
||||
batch_size_inference: 0
|
||||
do_sample: false
|
||||
max_length_inference: 256
|
||||
metric: GPT
|
||||
metric_gpt_model: gpt-3.5-turbo-0301
|
||||
min_length_inference: 2
|
||||
num_beams: 1
|
||||
num_history: 2
|
||||
repetition_penalty: 1.2
|
||||
stop_tokens: ''
|
||||
temperature: 0.3
|
||||
top_k: 0
|
||||
top_p: 1.0
|
||||
problem_type: text_causal_language_modeling
|
||||
tokenizer:
|
||||
add_prefix_space: false
|
||||
add_prompt_answer_tokens: false
|
||||
max_length: 512
|
||||
max_length_answer: 256
|
||||
max_length_prompt: 256
|
||||
padding_quantile: 1.0
|
||||
use_fast: true
|
||||
training:
|
||||
adaptive_kl_control: true
|
||||
advantages_gamma: 0.99
|
||||
advantages_lambda: 0.95
|
||||
batch_size: 10
|
||||
differential_learning_rate: 1.0e-05
|
||||
differential_learning_rate_layers: []
|
||||
drop_last_batch: true
|
||||
epochs: 3
|
||||
evaluate_before_training: false
|
||||
evaluation_epochs: 1.0
|
||||
grad_accumulation: 1
|
||||
gradient_clip: 0.0
|
||||
initial_kl_coefficient: 0.2
|
||||
kl_horizon: 10000
|
||||
kl_target: 6.0
|
||||
learning_rate: 0.0001
|
||||
lora: true
|
||||
lora_alpha: 16
|
||||
lora_dropout: 0.05
|
||||
lora_r: 4
|
||||
lora_target_modules: ''
|
||||
loss_function: TokenAveragedCrossEntropy
|
||||
offload_reward_model: false
|
||||
optimizer: AdamW
|
||||
ppo_batch_size: 1
|
||||
ppo_clip_policy: 0.2
|
||||
ppo_clip_value: 0.2
|
||||
ppo_epochs: 4
|
||||
ppo_generate_temperature: 1.0
|
||||
reward_model: OpenAssistant/reward-model-deberta-v3-large-v2
|
||||
save_best_checkpoint: false
|
||||
scaling_factor_value_loss: 0.1
|
||||
schedule: Cosine
|
||||
train_validation_data: false
|
||||
use_rlhf: false
|
||||
warmup_epochs: 0.0
|
||||
weight_decay: 0.0
|
||||
34
config.json
Normal file
34
config.json
Normal file
@@ -0,0 +1,34 @@
|
||||
{
|
||||
"_name_or_path": "EleutherAI/pythia-1b-deduped",
|
||||
"architectures": [
|
||||
"GPTNeoXForCausalLM"
|
||||
],
|
||||
"attention_probs_dropout_prob": 0.0,
|
||||
"bos_token_id": 0,
|
||||
"classifier_dropout": 0.1,
|
||||
"custom_pipelines": {
|
||||
"text-generation": {
|
||||
"impl": "h2oai_pipeline.H2OTextGenerationPipeline",
|
||||
"pt": "AutoModelForCausalLM"
|
||||
}
|
||||
},
|
||||
"eos_token_id": 0,
|
||||
"hidden_act": "gelu",
|
||||
"hidden_dropout_prob": 0.0,
|
||||
"hidden_size": 2048,
|
||||
"initializer_range": 0.02,
|
||||
"intermediate_size": 8192,
|
||||
"layer_norm_eps": 1e-05,
|
||||
"max_position_embeddings": 2048,
|
||||
"model_type": "gpt_neox",
|
||||
"num_attention_heads": 8,
|
||||
"num_hidden_layers": 16,
|
||||
"rotary_emb_base": 10000,
|
||||
"rotary_pct": 0.25,
|
||||
"tie_word_embeddings": false,
|
||||
"torch_dtype": "float16",
|
||||
"transformers_version": "4.30.1",
|
||||
"use_cache": true,
|
||||
"use_parallel_residual": true,
|
||||
"vocab_size": 50304
|
||||
}
|
||||
6
generation_config.json
Normal file
6
generation_config.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"_from_model_config": true,
|
||||
"bos_token_id": 0,
|
||||
"eos_token_id": 0,
|
||||
"transformers_version": "4.30.1"
|
||||
}
|
||||
42
h2oai_pipeline.py
Normal file
42
h2oai_pipeline.py
Normal file
@@ -0,0 +1,42 @@
|
||||
from transformers import TextGenerationPipeline
|
||||
from transformers.pipelines.text_generation import ReturnType
|
||||
|
||||
STYLE = "<|prompt|>{instruction}<|endoftext|><|answer|>"
|
||||
|
||||
|
||||
class H2OTextGenerationPipeline(TextGenerationPipeline):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
self.prompt = STYLE
|
||||
|
||||
def preprocess(
|
||||
self, prompt_text, prefix="", handle_long_generation=None, **generate_kwargs
|
||||
):
|
||||
prompt_text = self.prompt.format(instruction=prompt_text)
|
||||
return super().preprocess(
|
||||
prompt_text,
|
||||
prefix=prefix,
|
||||
handle_long_generation=handle_long_generation,
|
||||
**generate_kwargs,
|
||||
)
|
||||
|
||||
def postprocess(
|
||||
self,
|
||||
model_outputs,
|
||||
return_type=ReturnType.FULL_TEXT,
|
||||
clean_up_tokenization_spaces=True,
|
||||
):
|
||||
records = super().postprocess(
|
||||
model_outputs,
|
||||
return_type=return_type,
|
||||
clean_up_tokenization_spaces=clean_up_tokenization_spaces,
|
||||
)
|
||||
for rec in records:
|
||||
rec["generated_text"] = (
|
||||
rec["generated_text"]
|
||||
.split("<|answer|>")[1]
|
||||
.strip()
|
||||
.split("<|prompt|>")[0]
|
||||
.strip()
|
||||
)
|
||||
return records
|
||||
3
pytorch_model.bin
Normal file
3
pytorch_model.bin
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:bbe39a39f3a8ecbe6c55b34d468d16ac7111fdc78be13f0762d9ca4c9e6c4725
|
||||
size 2090752989
|
||||
8
special_tokens_map.json
Normal file
8
special_tokens_map.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"bos_token": "<|endoftext|>",
|
||||
"cls_token": "<|endoftext|>",
|
||||
"eos_token": "<|endoftext|>",
|
||||
"pad_token": "<|endoftext|>",
|
||||
"sep_token": "<|endoftext|>",
|
||||
"unk_token": "<|endoftext|>"
|
||||
}
|
||||
100529
tokenizer.json
Normal file
100529
tokenizer.json
Normal file
File diff suppressed because it is too large
Load Diff
9
tokenizer_config.json
Normal file
9
tokenizer_config.json
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"add_prefix_space": false,
|
||||
"bos_token": "<|endoftext|>",
|
||||
"clean_up_tokenization_spaces": true,
|
||||
"eos_token": "<|endoftext|>",
|
||||
"model_max_length": 1000000000000000019884624838656,
|
||||
"tokenizer_class": "GPTNeoXTokenizer",
|
||||
"unk_token": "<|endoftext|>"
|
||||
}
|
||||
Reference in New Issue
Block a user