Views
No views yet
reference-data-model:
datasets:
- OpenAssistant/oasst_top1_2023-08-25:
lang: "bg,ca,cs,da,de,en,es,fr,hr,hu,it,nl,pl,pt,ro,ru,sl,sr,sv,uk"
link: https://huggingface.co/datasets/OpenAssistant/oasst_top1_2023-08-25
model:
- Open-Orca/Mistral-7B-OpenOrca
Link:
https://huggingface.co/Open-Orca/Mistral-7B-OpenOrca
100 examples of generating:
- Link:
https://huggingface.co/NickyNicky/Mistral-7B-OpenOrca-oasst_top1_2023-08-25-v3/blob/main/output.xlsx
Activated training with:
- Link:
https://huggingface.co/blog/tomaarsen/attention-sinks
https://github.com/tomaarsen/attention_sinks
https://arxiv.org/abs/2309.17453
TRL:
- Link:
https://huggingface.co/docs/trl/index
https://huggingface.co/docs/trl/sft_trainer
flash-attention:
- Link:
https://github.com/Dao-AILab/flash-attention
https://arxiv.org/abs/2205.14135
Version:
- Link:
https://huggingface.co/NickyNicky/Mistral-7B-OpenOrca-oasst_top1_2023-08-25-v2
https://huggingface.co/NickyNicky/Mistral-7B-OpenOrca-oasst_top1_2023-08-25-v3
1# attention-sinks
2pip install attention_sinks
3
4# flash-attn
5!export CUDA_HOME=/usr/local/cuda-11.8
6!MAX_JOBS=4 pip install flash-attn --no-build-isolation -qqq
7!pip install git+"https://github.com/HazyResearch/flash-attention.git#subdirectory=csrc/rotary" -qqq1import torch, transformers,torchvision
2torch.__version__,transformers.__version__, torchvision.__version__
3#OUTPUTS: ('2.0.1+cu118', '4.34.0', '0.15.2+cu118')1
2from transformers import (
3 AutoModelForCausalLM,
4 AutoTokenizer,
5 BitsAndBytesConfig,
6 HfArgumentParser,
7 TrainingArguments,
8 pipeline,
9 logging,
10 GenerationConfig,
11 TextIteratorStreamer,
12)
13
14from attention_sinks import AutoModelForCausalLM
15
16import torch
17
18# model_id = 'Open-Orca/Mistral-7B-OpenOrca'
19model_id='NickyNicky/Mixtral-2x7b-OpenOrca-oasst_top1_2023-08-25-v1.0'
20
21model = AutoModelForCausalLM.from_pretrained(model_id,
22 device_map="auto",
23 trust_remote_code=True,
24 torch_dtype=torch.bfloat16,
25 load_in_4bit=True,
26 low_cpu_mem_usage= True,
27 #use_flash_attention_2=True, #GPU A100 or GPU supported
28
29 attention_sink_size=4,
30 attention_sink_window_size=1024, #512, # <- Low for the sake of faster generation
31 )
32
33max_length=2048
34print("max_length",max_length)
35
36
37tokenizer = AutoTokenizer.from_pretrained(model_id,
38 # use_fast = False,
39 max_length=max_length,)
40
41tokenizer.pad_token = tokenizer.eos_token
42tokenizer.padding_side = 'right'
43
44#EXAMPLE #1
45txt="""<|im_start|>user
46I'm looking for an efficient Python script to output prime numbers. Can you help me out? I'm interested in a script that can handle large numbers and output them quickly. Also, it would be great if the script could take a range of numbers as input and output all the prime numbers within that range. Can you generate a script that fits these requirements? Thanks!<|im_end|>
47<|im_start|>assistant
48"""
49
50#EXAMPLE #2
51txt="""<|im_start|>user
52Estoy desarrollando una REST API con Nodejs, y estoy tratando de aplicar algún sistema de seguridad, ya sea con tokens o algo similar, me puedes ayudar?<|im_end|>
53<|im_start|>assistant
54"""
55
56inputs = tokenizer.encode(txt, return_tensors="pt").to("cuda")
57
58generation_config = GenerationConfig(
59 max_new_tokens=max_new_tokens,
60 temperature=0.7,
61 top_p=0.9,
62 top_k=len_tokens,
63 repetition_penalty=1.11,
64 do_sample=True,
65 # pad_token_id=tokenizer.eos_token_id,
66 # eos_token_id=tokenizer.eos_token_id,
67 # use_cache=True,
68 # stopping_criteria= StoppingCriteriaList([stopping_criteria]),
69 )
70outputs = model.generate(generation_config=generation_config,
71 input_ids=inputs,)
72tokenizer.decode(outputs[0], skip_special_tokens=False) #Trueexperts:
- source_model: NickyNicky/Mistral-7B-OpenOrca-oasst_top1_2023-08-25-v2
positive_prompts:
- ""
- source_model: NickyNicky/Mistral-7B-OpenOrca-oasst_top1_2023-08-25-v3
positive_prompts:
- ""
base_model: NickyNicky/Mistral-7B-OpenOrca-oasst_top1_2023-08-25-v3
gate_mode: random # one of "hidden", "cheap_embed", or "random"
dtype: bfloat16 # output dtype (float32, float16, or bfloat16)