Clone77 commited on
Commit
acdd674
·
verified ·
1 Parent(s): 04f2d71

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -2
app.py CHANGED
@@ -3,7 +3,7 @@ import cv2
3
  import numpy as np
4
  import os
5
  from PIL import Image
6
- from transformers import pipeline, AutoModelForCausalLM, AutoTokenizer
7
  from langchain.chains import LLMChain
8
  from langchain.prompts import PromptTemplate
9
  from langchain_huggingface import ChatHuggingFace
@@ -50,8 +50,9 @@ def get_image_context(image, question):
50
 
51
  # 🔥 Corrected LangChain setup
52
  model_id = "meta-llama/Llama-3.2-3B-Instruct"
 
53
  tokenizer = AutoTokenizer.from_pretrained(model_id, token=hf,use_fast=False)
54
- model = AutoModelForCausalLM.from_pretrained(model_id, token=hf)
55
 
56
  llm = ChatHuggingFace(llm=model, tokenizer=tokenizer)
57
 
 
3
  import numpy as np
4
  import os
5
  from PIL import Image
6
+ from transformers import pipeline, AutoModelForCausalLM, AutoTokenizer,BitsAndBytesConfig
7
  from langchain.chains import LLMChain
8
  from langchain.prompts import PromptTemplate
9
  from langchain_huggingface import ChatHuggingFace
 
50
 
51
  # 🔥 Corrected LangChain setup
52
  model_id = "meta-llama/Llama-3.2-3B-Instruct"
53
+ bnb_config = BitsAndBytesConfig(load_in_4bit=True)
54
  tokenizer = AutoTokenizer.from_pretrained(model_id, token=hf,use_fast=False)
55
+ model = AutoModelForCausalLM.from_pretrained(model_id, token=hf,quantization_config=bnb_config,)
56
 
57
  llm = ChatHuggingFace(llm=model, tokenizer=tokenizer)
58