File size: 11,840 Bytes
798e8e0 b7631f6 798e8e0 b7631f6 798e8e0 b7631f6 ebc4b1d b7631f6 798e8e0 b7631f6 798e8e0 b7631f6 798e8e0 b7631f6 798e8e0 b7631f6 798e8e0 b7631f6 798e8e0 b7631f6 c4db575 798e8e0 9933d95 798e8e0 b7631f6 798e8e0 b7631f6 798e8e0 195f57d 798e8e0 58e1998 798e8e0 b7631f6 68a194b b7631f6 798e8e0 b7631f6 798e8e0 b7631f6 798e8e0 b7631f6 ec7fa2e b7631f6 e7e8fa0 ec7fa2e e7e8fa0 ec7fa2e e7e8fa0 b7631f6 |
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 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 |
---
license: apache-2.0
datasets:
- NickyNicky/oasst2_clusters
- OpenAssistant/oasst2
model:
- google/gemma-2b-it
language:
- bg
- ca
- cs
- da
- de
- en
- es
- fr
- hr
- hu
- it
- nl
- pl
- pt
- ro
- ru
- sl
- sr
- sv
- uk
library_name: transformers
widget:
- text: |
<bos><start_of_turn>system\nYou are a helpful AI assistant.<end_of_turn>\n<start_of_turn>user\nescribe una historia de 100 palabras<end_of_turn>\n<start_of_turn>model\n
---
![image/png](https://cdn-uploads.huggingface.co/production/uploads/641b435ba5f876fe30c5ae0a/YXqUXFjX8uIJT-mdOnM1h.png)
```
reference data model:
datasets:
- 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/NickyNicky/oasst2_clusters
model:
- google/gemma-2b-it
Link:
https://huggingface.co/google/gemma-2b-it
base fine tune: google/gemma-2b-it
Epoch: 3
per_device_train_batch_size: 16
all clustes
future experts: 1
Eval model:
- link:
soon
```
## train/loss: 0.4943
![image/png](https://cdn-uploads.huggingface.co/production/uploads/641b435ba5f876fe30c5ae0a/wRZtjbfYp2OcG16yeNQbG.png)
## dataset tokens:
![image/png](https://cdn-uploads.huggingface.co/production/uploads/641b435ba5f876fe30c5ae0a/xmf6SCGVtFpkJBrtIalj1.png)
```Python
!python -m pip install --upgrade pip
!pip install "torch>=2.1.1" -U
!pip install -q datasets trl peft bitsandbytes sentencepiece wandb
!pip install -q accelerate safetensors deepspeed
!pip install -q scipy ninja -U
!pip install -q -U transformers==4.38.0
!pip install flash-attn==2.5.5 --no-build-isolation
```
## Version
```py
import torch
torch.__version__
#OUTPUTS: ('2.2.0+cu121' )
```
## How to use
```py
from transformers import (
AutoModelForCausalLM,
AutoTokenizer,
BitsAndBytesConfig,
HfArgumentParser,
TrainingArguments,
pipeline,
logging,
GenerationConfig,
TextIteratorStreamer,
)
from transformers import StoppingCriteria, StoppingCriteriaList
import torch
model_id='NickyNicky/gemma-2b-it_oasst2_all_chatML_Unsloth_V1'
model = AutoModelForCausalLM.from_pretrained(model_id,
device_map="auto",
trust_remote_code=True,
torch_dtype=torch.bfloat16,
attn_implementation="flash_attention_2",
# load_in_4bit=True,
# low_cpu_mem_usage= True,
)
max_length=2048
print("max_length",max_length)
tokenizer = AutoTokenizer.from_pretrained(model_id,
# use_fast = False,
max_length=max_length,)
class ListOfTokensStoppingCriteria(StoppingCriteria):
"""
Clase para definir un criterio de parada basado en una lista de tokens específicos.
"""
def __init__(self, tokenizer, stop_tokens):
self.tokenizer = tokenizer
# Codifica cada token de parada y guarda sus IDs en una lista
self.stop_token_ids_list = [tokenizer.encode(stop_token, add_special_tokens=False) for stop_token in stop_tokens]
def __call__(self, input_ids, scores, **kwargs):
# Verifica si los últimos tokens generados coinciden con alguno de los conjuntos de tokens de parada
for stop_token_ids in self.stop_token_ids_list:
len_stop_tokens = len(stop_token_ids)
if len(input_ids[0]) >= len_stop_tokens:
if input_ids[0, -len_stop_tokens:].tolist() == stop_token_ids:
return True
return False
# Uso del criterio de parada personalizado
stop_tokens = ["<end_of_turn>"] # Lista de tokens de parada
# Inicializa tu criterio de parada con el tokenizer y la lista de tokens de parada
stopping_criteria = ListOfTokensStoppingCriteria(tokenizer, stop_tokens)
# Añade tu criterio de parada a una StoppingCriteriaList
stopping_criteria_list = StoppingCriteriaList([stopping_criteria])
#EXAMPLE #1
input_text = f"""<bos><start_of_turn>system
You are a helpful AI assistant.<end_of_turn>
<start_of_turn>user
**News:**
he Texas Blockchain Council (TBC) and Bitcoin mining firm Riot Platforms have won a favorable ruling from a United States District Judge in a lawsuit against several United States energy officials.
On February 22, Cointelegraph reported that the TBC and Riot alleged the U.S. Department of Energy, Energy Information Administration (EIA), Office of Management and Budget (OMB) and their leadership sought an “invasive” data collection from cryptocurrency miners.
According to a February 23 filing in the United States District Court for the Western District of Texas, the TBC and Riot convinced the judge that irreversible harm would happen without a temporary restraining order (TRO) against further data collection.
As a result, the court enforced a TRO which prohibits the EIA from requiring crypto miners to respond to the survey, as well as prohibiting the EIA from sharing any data that has already been received from the survey.
“The Court finds that Plaintiffs have shown through a verified complaint and supporting evidence that immediate and irreparable injury, loss, or damage will result if a TRO is not issued.”
Instruccion:
- responde en español.
- has un análisis sobre el contexto de la noticia y buscar información relevante para poder responder satisfactoriamente.
- has 5 preguntas importantes y sus respuestas.
en español responde solo en json:
```json
{
"analisis_noticia": "",
"preguntas_respuestas": [
{
"pregunta": "",
"respuesta": ""
}
]
}```<end_of_turn>
<start_of_turn>model
"""
inputs = tokenizer.encode(txt,
return_tensors="pt",
add_special_tokens=False).to("cuda:0")
max_new_tokens=1500
generation_config = GenerationConfig(
max_new_tokens=max_new_tokens,
temperature=0.15,
# top_p=0.55,
top_k=50,
repetition_penalty=1.1,
do_sample=True,
)
outputs = base_model.generate(generation_config=generation_config,
input_ids=inputs,
stopping_criteria=stopping_criteria_list,)
print(tokenizer.decode(outputs[0], skip_special_tokens=False) )
```
```
'''
### OUTPUT EXAMPLE
<start_of_turn>model
{
"analisis_noticia": "El Texas Blockchain Council (TBC) y la empresa minadora de Bitcoins Riot Platforms han obtenido una decisión favorable de un juez federal en una demanda contra varias autoridades estadounidenses.",
"preguntas_respuestas": [
{
"pregunta": "¿Cuáles son los cargos que enfrentan las dos entidades?";
"respuesta": "La acusación involucra alegaciones de acoso regulatorio por parte del Departamento de Energía de Estados Unidos, la Administración de Información Energética (EIA) y la Oficina de Planificación del Gobierno (OMB), junto con su liderazgo."
},
{
"pregunta": "¿Por qué les oponen el tribunal federal?";
"respuesta": "Según una denuncia verificada, las entidades allegejan que la administración estadounidense seeks una recopilación irreversible de datos de los mineros de criptomonedas."
},
{
"pregunta": "¿Qué medidas legales han tomado los defensores de los derechos de los mineros?";
"respuesta": "Una orden de restricción irreversible (TRO) ha sido otorgada para evitar cualquier daño irremediable sin necesidad de un informe de impacto."
},
{
"pregunta": "¿Qué restricciones se han establecido en relación con la recopilación de datos?");
"respuesta": "Se ha prohibido cualquier información que haya sido recibida a partir de la encuesta de mineros a ser compartida."
},
{
"pregunta": "¿Cuál es el objetivo principal de esta acción?";
"respuesta": "El objetivo principal es impedir que la EIA requiera a los mineros de criptomonedas responda a la encuesta.";
}
]
}<end_of_turn>
'''
```
![image/png](https://cdn-uploads.huggingface.co/production/uploads/641b435ba5f876fe30c5ae0a/9qnFieRpV4uGvVRP9osGp.png)
```
## example 2
<bos><start_of_turn>system
You are a helpful AI assistant.<end_of_turn>
<start_of_turn>user
**News:**
he Texas Blockchain Council (TBC) and Bitcoin mining firm Riot Platforms have won a favorable ruling from a United States District Judge in a lawsuit against several United States energy officials.
On February 22, Cointelegraph reported that the TBC and Riot alleged the U.S. Department of Energy, Energy Information Administration (EIA), Office of Management and Budget (OMB) and their leadership sought an “invasive” data collection from cryptocurrency miners.
According to a February 23 filing in the United States District Court for the Western District of Texas, the TBC and Riot convinced the judge that irreversible harm would happen without a temporary restraining order (TRO) against further data collection.
As a result, the court enforced a TRO which prohibits the EIA from requiring crypto miners to respond to the survey, as well as prohibiting the EIA from sharing any data that has already been received from the survey.
“The Court finds that Plaintiffs have shown through a verified complaint and supporting evidence that immediate and irreparable injury, loss, or damage will result if a TRO is not issued.”
Instruccion:
- responde en español.
- haz un análisis sobre el contexto de la noticia y buscar información relevante para poder responder satisfactoriamente.
- haz 5 preguntas diferentes y sus respuestas.
<end_of_turn>
<start_of_turn>model
Aquí tienes una respuesta al contexto de la noticia:
En la noticia se habla del éxito de un juicio contra funcionarios estadounidenses que intentaron recopilar datos irreversibles de los mineros de criptomonedas.
El Texas Blockchain Council (TBC) y la empresa minera Riot Platforms argumentaron que este tipo de recolección de datos irreversible causaría daño irreparable y no podría esperar que la cortefdfecha un decreto de suspensión temporal (TRO) para evitar eso.
Como resultado, la corte fdefundió un TRO que prohíbe a la Administración de Energías del Departamento de Energía (EIA) continuar con la recolección de datos.
Esto significa que los mineros de criptomonedas no tendrán que responder a la encuesta de la EIA ni obligéen de compartir cualquier información recibida.
Esta noticia demuestra el apoyo creciente a las nuevas tecnologías como la criptomoneda y a su economía global.
Sin embargo, también muestra cómo los esfuerzos gubernamentales pueden tener consecuencias adversas para la privacidad y la seguridad de los ciudadanos.
Preguntas y respuestas:
¿Cuál es el Texas Blockchain Council?
Respuesta:
Es un consejo estatal para la adopción y uso de la tecnología blockchain en Texas.
¿Qué charges les reprovocarán los funcionarios de la Junta gubernativa estadounidense?
Respuesta:
Les reprovocarán que intentan recopilar datos irreversibles sin su consentimiento.
¿Cómo ha sido interpretado el derecho de los ciudadanos a la privacidad en tiempos de la era digital?
Respuesta:
Ha sido interpretado como un derecho fundamental que no puede ser infringido sin causa justa.
¿Qué es el derecho a la información?
Respuesta:
Es el derecho de tener acceso a toda la información pública que pueda resultar útil para su vida.
¿Por qué los mineros de criptomonedas están enfadados?
Respuesta:
Porque sus derechos y libertades están siendo infringidos por los funcionarios gubernamentales.<end_of_turn>
time LLM:
CPU times: user 14.5 s, sys: 0 ns, total: 14.5 s
Wall time: 15 s
``` |