menikev commited on
Commit
651f036
·
verified ·
1 Parent(s): cd57fb0

Update crypto_analysis_agents.py

Browse files
Files changed (1) hide show
  1. 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 the GPT-Neo 2.7B model and tokenizer
12
- model_name = "EleutherAI/gpt-neo-2.7B"
13
  tokenizer = AutoTokenizer.from_pretrained(model_name)
14
  model = AutoModelForCausalLM.from_pretrained(model_name)
15
-
16
- def generate_report(self, input_text):
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
- max_length=1024, # Use max_length instead of max_new_tokens
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
- # Wrap the pipeline in a HuggingFacePipeline
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 on our geo-politics and economic policies impact on crypto",
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,