Spaces:
Sleeping
Sleeping
Update crypto_analysis_agents.py
Browse files- crypto_analysis_agents.py +9 -15
crypto_analysis_agents.py
CHANGED
@@ -8,37 +8,31 @@ import os
|
|
8 |
|
9 |
class CryptoAnalysisAgents:
|
10 |
def __init__(self):
|
11 |
-
# Load
|
12 |
-
model_name = "
|
13 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
14 |
model = AutoModelForCausalLM.from_pretrained(model_name)
|
15 |
-
|
16 |
-
|
17 |
-
truncated_input = self._truncate_input(input_text)
|
18 |
-
result = self.pipe(truncated_input, max_length=1024, max_new_tokens=512)
|
19 |
-
return result[0]['generated_text']
|
20 |
-
|
21 |
-
# Create the text-generation pipeline
|
22 |
pipe = pipeline(
|
23 |
"text-generation",
|
24 |
model=model,
|
25 |
tokenizer=tokenizer,
|
26 |
-
|
27 |
do_sample=True,
|
28 |
temperature=0.7,
|
29 |
top_p=0.95,
|
30 |
top_k=50,
|
31 |
-
repetition_penalty=1.1
|
32 |
-
pad_token_id=tokenizer.eos_token_id
|
33 |
)
|
34 |
-
|
35 |
-
#
|
36 |
self.llm = HuggingFacePipeline(pipeline=pipe)
|
37 |
|
38 |
def market_analyst(self):
|
39 |
return Agent(
|
40 |
role='Crypto Market Analyst',
|
41 |
-
goal="Provide in-depth industry, market analysis and insights for cryptocurrencies. You also provide insight on
|
42 |
backstory="""You are a seasoned crypto market analyst with years of experience in blockchain technology and cryptocurrency markets. Your expertise helps clients navigate the volatile crypto landscape.""",
|
43 |
verbose=True,
|
44 |
llm=self.llm,
|
|
|
8 |
|
9 |
class CryptoAnalysisAgents:
|
10 |
def __init__(self):
|
11 |
+
# Load a smaller, open-source model
|
12 |
+
model_name = "facebook/opt-350m" # You can change this to another open-source model
|
13 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
14 |
model = AutoModelForCausalLM.from_pretrained(model_name)
|
15 |
+
|
16 |
+
# Create a text-generation pipeline
|
|
|
|
|
|
|
|
|
|
|
17 |
pipe = pipeline(
|
18 |
"text-generation",
|
19 |
model=model,
|
20 |
tokenizer=tokenizer,
|
21 |
+
max_new_tokens=512,
|
22 |
do_sample=True,
|
23 |
temperature=0.7,
|
24 |
top_p=0.95,
|
25 |
top_k=50,
|
26 |
+
repetition_penalty=1.1
|
|
|
27 |
)
|
28 |
+
|
29 |
+
# Create a LangChain wrapper around the Hugging Face pipeline
|
30 |
self.llm = HuggingFacePipeline(pipeline=pipe)
|
31 |
|
32 |
def market_analyst(self):
|
33 |
return Agent(
|
34 |
role='Crypto Market Analyst',
|
35 |
+
goal="Provide in-depth industry, market analysis and insights for cryptocurrencies. You also provide insight on our geo-politics and economic policies impact on crypto",
|
36 |
backstory="""You are a seasoned crypto market analyst with years of experience in blockchain technology and cryptocurrency markets. Your expertise helps clients navigate the volatile crypto landscape.""",
|
37 |
verbose=True,
|
38 |
llm=self.llm,
|