algorythmtechnologies commited on
Commit
3a3e728
·
1 Parent(s): 40a53b0

fix: Add workaround for incorrect base model path

Browse files
Files changed (1) hide show
  1. app.py +11 -2
app.py CHANGED
@@ -1,6 +1,6 @@
1
  import gradio as gr
2
  import torch
3
- from transformers import AutoTokenizer, TextIteratorStreamer, AutoModelForCausalLM
4
  import requests
5
  import json
6
  from peft import PeftModel
@@ -24,9 +24,18 @@ if not hf_token:
24
  # Load the tokenizer from the Hub, using the token for private models
25
  tokenizer = AutoTokenizer.from_pretrained(BASE_MODEL_PATH, use_auth_token=hf_token)
26
 
27
- # Load the base model from the Hub
 
 
 
 
 
 
 
 
28
  base_model = AutoModelForCausalLM.from_pretrained(
29
  BASE_MODEL_PATH,
 
30
  trust_remote_code=True,
31
  low_cpu_mem_usage=True,
32
  torch_dtype=torch.bfloat16,
 
1
  import gradio as gr
2
  import torch
3
+ from transformers import AutoTokenizer, TextIteratorStreamer, AutoModelForCausalLM, AutoConfig
4
  import requests
5
  import json
6
  from peft import PeftModel
 
24
  # Load the tokenizer from the Hub, using the token for private models
25
  tokenizer = AutoTokenizer.from_pretrained(BASE_MODEL_PATH, use_auth_token=hf_token)
26
 
27
+ from transformers import AutoConfig
28
+
29
+ # Load the config from the user's repo
30
+ config = AutoConfig.from_pretrained(BASE_MODEL_PATH, use_auth_token=hf_token)
31
+
32
+ # Correct the base model path in the config
33
+ config._name_or_path = "deepseek-ai/DeepSeek-Coder-V2-Lite-Instruct"
34
+
35
+ # Load the base model from the Hub using the corrected config
36
  base_model = AutoModelForCausalLM.from_pretrained(
37
  BASE_MODEL_PATH,
38
+ config=config,
39
  trust_remote_code=True,
40
  low_cpu_mem_usage=True,
41
  torch_dtype=torch.bfloat16,