JiakaiDu commited on
Commit
f038dc5
1 Parent(s): 30458b7

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. Test_RAG.py +11 -10
Test_RAG.py CHANGED
@@ -60,7 +60,7 @@ if not text_example_cn_path.exists():
60
  f.write(content.read())
61
 
62
  model_language = "English"
63
- llm_model_id= "llama-3.2-3b-instruct" #"llama-3-8b-instruct"
64
  llm_model_configuration = SUPPORTED_LLM_MODELS[model_language][llm_model_id]
65
  print(f"Selected LLM model {llm_model_id}")
66
  prepare_int4_model = True # Prepare INT4 model
@@ -291,7 +291,8 @@ if llm_model_id == "red-pajama-3b-chat" and "GPU" in core.available_devices and
291
  ov_config["INFERENCE_PRECISION_HINT"] = "f32"
292
 
293
  llm = HuggingFacePipeline.from_model_id(
294
- model_id="meta-llama/Llama-3.2-3B-Instruct", #“meta-llama/Meta-Llama-3-8B"
 
295
  task="text-generation",
296
  backend="openvino",
297
  model_kwargs={
@@ -301,14 +302,14 @@ llm = HuggingFacePipeline.from_model_id(
301
  },
302
  pipeline_kwargs={"max_new_tokens": 2},
303
  )
304
- # 设置 pad_token_id 为 eos_token_id
305
- from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
306
- tokenizer = AutoTokenizer.from_pretrained('meta-llama/Llama-3.2-3B-Instruct')
307
- if tokenizer.pad_token_id is None:
308
- tokenizer.pad_token_id = tokenizer.eos_token_id
309
- # # 同时确保 HuggingFacePipeline 使用的 tokenizer 也设置了 pad_token_id
310
- llm.pipeline.tokenizer.pad_token_id = tokenizer.pad_token_id
311
- # llm.invoke("2 + 2 =")
312
  import re
313
  from typing import List
314
  from langchain.text_splitter import (
 
60
  f.write(content.read())
61
 
62
  model_language = "English"
63
+ llm_model_id = "llama-3-8b-instruct" #"llama-3.2-3b-instruct" #"llama-3-8b-instruct"
64
  llm_model_configuration = SUPPORTED_LLM_MODELS[model_language][llm_model_id]
65
  print(f"Selected LLM model {llm_model_id}")
66
  prepare_int4_model = True # Prepare INT4 model
 
291
  ov_config["INFERENCE_PRECISION_HINT"] = "f32"
292
 
293
  llm = HuggingFacePipeline.from_model_id(
294
+ model_id= "meta-llama/Meta-Llama-3-8B"
295
+ #meta-llama/Meta-Llama-3-8B------------/meta-llama/Llama-3.2-3B-Instruct
296
  task="text-generation",
297
  backend="openvino",
298
  model_kwargs={
 
302
  },
303
  pipeline_kwargs={"max_new_tokens": 2},
304
  )
305
+ # # 设置 pad_token_id 为 eos_token_id
306
+ # from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
307
+ # tokenizer = AutoTokenizer.from_pretrained('meta-llama/Llama-3.2-3B-Instruct')
308
+ # if tokenizer.pad_token_id is None:
309
+ # tokenizer.pad_token_id = tokenizer.eos_token_id
310
+ # # # 同时确保 HuggingFacePipeline 使用的 tokenizer 也设置了 pad_token_id
311
+ # llm.pipeline.tokenizer.pad_token_id = tokenizer.pad_token_id
312
+ llm.invoke("2 + 2 =")
313
  import re
314
  from typing import List
315
  from langchain.text_splitter import (