Ankitajadhav commited on
Commit
1289ea0
·
verified ·
1 Parent(s): 59467a5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -7
app.py CHANGED
@@ -9,6 +9,9 @@ import chromadb
9
  from datasets import load_dataset
10
  from transformers import AutoModelForCausalLM, AutoTokenizer
11
  import gradio as gr
 
 
 
12
 
13
  # Function to clear the cache
14
  def clear_cache(model_name):
@@ -36,14 +39,11 @@ class VectorStore:
36
  # Method to populate the vector store with embeddings from a dataset
37
  def populate_vectors(self, dataset, batch_size=100):
38
  # Use dataset streaming
39
- dataset = load_dataset('Thefoodprocessor/recipe_new_with_features_full', split='train', streaming=True)
40
 
41
  # Process in batches
42
  texts = []
43
- max_examples = 15
44
  for i, example in enumerate(dataset):
45
- if i >= max_examples:
46
- break
47
  title = example['title_cleaned']
48
  recipe = example['recipe_new']
49
  meal_type = example['meal_type']
@@ -79,9 +79,14 @@ vector_store.populate_vectors(dataset=None)
79
 
80
  # Load the model and tokenizer
81
  # text generation model
82
- model_name = "meta-llama/Meta-Llama-3-8B"
83
- tokenizer = AutoTokenizer.from_pretrained(model_name)
84
- model = AutoModelForCausalLM.from_pretrained(model_name)
 
 
 
 
 
85
 
86
  # Define the chatbot response function
87
  def chatbot_response(user_input):
 
9
  from datasets import load_dataset
10
  from transformers import AutoModelForCausalLM, AutoTokenizer
11
  import gradio as gr
12
+ # import packages load LLM model
13
+ from gpt4all import GPT4All
14
+ from pathlib import Path
15
 
16
  # Function to clear the cache
17
  def clear_cache(model_name):
 
39
  # Method to populate the vector store with embeddings from a dataset
40
  def populate_vectors(self, dataset, batch_size=100):
41
  # Use dataset streaming
42
+ dataset = load_dataset('Thefoodprocessor/recipe_new_with_features_full', split='train[:1500]')
43
 
44
  # Process in batches
45
  texts = []
 
46
  for i, example in enumerate(dataset):
 
 
47
  title = example['title_cleaned']
48
  recipe = example['recipe_new']
49
  meal_type = example['meal_type']
 
79
 
80
  # Load the model and tokenizer
81
  # text generation model
82
+ # model_name = "meta-llama/Meta-Llama-3-8B"
83
+ # tokenizer = AutoTokenizer.from_pretrained(model_name)
84
+ # model = AutoModelForCausalLM.from_pretrained(model_name)
85
+
86
+ # load model orca-mini general purpose model
87
+ model_name = 'mistral-7b-openorca.gguf2.Q4_0.gguf'
88
+ model_path = Path.home() / '.cache' / 'gpt4all'
89
+ model = GPT4All(model_name=model_name, model_path=model_path)
90
 
91
  # Define the chatbot response function
92
  def chatbot_response(user_input):