metadata
language:
- es
- en
library_name: transformers
pipeline_tag: text-generation
tags:
- finance
Descripcion.
Este modelo de IA es competente en la comprensión y análisis de noticias financieras y de la bolsa de valores. Puede interpretar y procesar información relacionada con los mercados financieros, incluyendo tendencias bursátiles, informes económicos y análisis de inversiones. Además, tiene la capacidad de comprender y comunicarse de manera efectiva tanto en español como en inglés, lo que le permite interactuar con usuarios y fuentes de información en ambos idiomas de manera fluida. Asimismo, el modelo puede trabajar con grafos en formato JSON, permitiendo la visualización y análisis de estructuras de datos.
Code.
import torch,gc
import transformers
from transformers import AutoModelForCausalLM, AutoTokenizer, TrainingArguments, BitsAndBytesConfig
from datasets import load_dataset
from peft import LoraConfig, PeftModel, get_peft_model, prepare_model_for_kbit_training
from transformers import (
AutoModelForCausalLM,
AutoTokenizer,
BitsAndBytesConfig,
HfArgumentParser,
TrainingArguments,
pipeline,
logging,
GenerationConfig,
TextIteratorStreamer,
)
from transformers import StoppingCriteria, StoppingCriteriaList
import os
model_id="NickyNicky/Financial_graph"
max_seq_length=4048
tokenizer = AutoTokenizer.from_pretrained(model_id,
token=access_token,
max_length=max_seq_length)
model = AutoModelForCausalLM.from_pretrained(model_id,
# quantization_config=bnb_config,
device_map={"":0},
token=access_token,
attn_implementation="flash_attention_2",
torch_dtype=torch.bfloat16
).eval()
# dpo_trainer.model.config.use_cache = True # silence the warnings. Please re-enable for inference!
# tokenizer.padding_side='left'
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])
prompt= """<bos><start_of_turn>system
Eres un agente experto en finanzas multilenguaje.<end_of_turn>
<start_of_turn>user
**news:**
In a sudden decision, investment firm 21Shares submitted a filing to the Securities and Exchange Commission in the late afternoon of Friday, May 31, to rename its proposed spot Ether
ETH
tickers down
$3,686
exchange-traded fund (ETF) and to remove ARK Invest from the application.
A spokesperson for ARK Invest later confirmed the firm decided not to move forward with the crypto product, citing a need to reassess its investment strategy. The move raised concerns among the crypto community concerning the short-term viability of the newly approved ETFs.
During an interview on June 5, United States Securities and Exchange Commission (SEC) Chair Gary Gensler suggested a delay in final approvals for asset managers. ETFs will “take some time,” said Gensler. The SEC has yet to sign off on S-1 registration statements from applicants.
ARK Invest and 21Shares will remain partners on their spot Bitcoin
BTC
tickers down
$69,346
ETF, launched in January.
This week’s Crypto Biz also explores Galaxy Digital’s tokenized loan for Animoca Brands, Avail’s fundraising, the Toposware acquisition, and Bitcoin miners’ first reports since the halving.
Galaxy Digital uses historic violin NFT to secure loan
Michael Novogratz’s Galaxy Digital and Animoca Brands co-founder Yat Siu have tokenized a Stradivarius violin from 1708 to use as collateral for a multimillion-dollar loan. On June 4, Galaxy reportedly lent an undisclosed amount of funds to Siu, who used the 316-year-old violin he owned as collateral. The digital assets firm turned the violin into a nonfungible token (NFT) and will hold the NFT and the physical version until Siu settles the loan. The violin once belonged to the Russian Empress Catherine the Great.
genera un grafo de razonamiento que contenga nodes: 10 y edges: 20<end_of_turn>
<start_of_turn>model
"""
input= tokenizer(prompt,
return_tensors="pt",
add_special_tokens=False).to(model.device)
max_new_tokens=1500
generation_config = GenerationConfig(
max_new_tokens = max_new_tokens,
temperature = .3,
# top_p=0.55,
# top_k = 50,
# repetition_penalty = 1.1,
do_sample=True,
)
outputs = model.generate(**input,
generation_config=generation_config,
stopping_criteria=stopping_criteria_list,
)
print(tokenizer.decode(outputs[0], skip_special_tokens=False) )
##output:
# {'nodes': [{'entity': 'ARK Invest', 'type': 'Organization'}, {'entity': '21Shares', 'type': 'Organization'}, {'entity': 'SEC', 'type': 'Organization'}, {'entity': 'Gary Gensler', 'type': 'Person'}, {'entity': 'United States Securities and Exchange Commission', 'type': 'Organization'}, {'entity': 'Galaxy Digital', 'type': 'Organization'}, {'entity': 'Animoca Brands', 'type': 'Organization'}, {'entity': 'Toposware', 'type': 'Organization'}, {'entity': 'Bitcoin miners', 'type': 'Organization'}, {'entity': 'S-1 registration statements', 'type': 'Document'}], 'edges': [{'from': 'ARK Invest', 'to': '21Shares', 'relation': 'ASSOCIATED_WITH'}, {'from': 'ARK Invest', 'to': 'SEC', 'relation': 'ASSOCIATED_WITH'}, {'from': 'ARK Invest', 'to': 'Gary Gensler', 'relation': 'ASSOCIATED_WITH'}, {'from': '21Shares', 'to': 'SEC', 'relation': 'ASSOCIATED_WITH'}, {'from': '21Shares', 'to': 'Gary Gensler', 'relation': 'ASSOCIATED_WITH'}, {'from': 'SEC', 'to': 'Gary Gensler', 'relation': 'WORKED_AT'}, {'from': 'SEC', 'to': 'United States Securities and Exchange Commission', 'relation': 'PART_OF'}, {'from': 'Galaxy Digital', 'to': 'Animoca Brands', 'relation': 'ASSOCIATED_WITH'}, {'from': 'Galaxy Digital', 'to': 'Toposware', 'relation': 'ASSOCIATED_WITH'}, {'from': 'Galaxy Digital', 'to': 'Bitcoin miners', 'relation': 'ASSOCIATED_WITH'}, {'from': 'Galaxy Digital', 'to': 'S-1 registration statements', 'relation': 'ASSOCIATED_WITH'}, {'from': 'Animoca Brands', 'to': 'Toposware', 'relation': 'ASSOCIATED_WITH'}, {'from': 'Toposware', 'to': 'Bitcoin miners', 'relation': 'ASSOCIATED_WITH'}, {'from': 'Bitcoin miners', 'to': 'S-1 registration statements', 'relation': 'ASSOCIATED_WITH'}, {'from': 'S-1 registration statements', 'to': 'SEC', 'relation': 'ASSOCIATED_WITH'}, {'from': 'S-1 registration statements', 'to': 'Galaxy Digital', 'relation': 'ASSOCIATED_WITH'}, {'from': 'S-1 registration statements', 'to': 'Animoca Brands', 'relation': 'ASSOCIATED_WITH'}, {'from': 'S-1 registration statements', 'to': 'Toposware', 'relation': 'ASSOCIATED_WITH'}, {'from': 'S-1 registration statements', 'to': 'Bitcoin miners', 'relation': 'ASSOCIATED_WITH'}, {'from': 'S-1 registration statements', 'to': '21Shares', 'relation': 'ASSOCIATED_WITH'}]}
https://huggingface.co/NickyNicky/Financial_graph/blob/main/3d_graph%20(1).html
better than BloombergGPT :V
colab
https://colab.research.google.com/drive/1-D7kgig6ODqhjCPaQBrZ8QG2OWsS29ML?usp=sharing