langchain/libs/partners/huggingface/tests/unit_tests
Teruaki Ishizaki aeb42dc900
partners: Fixed the procedure of initializing pad_token_id (#29500)
- **Description:** Add to check pad_token_id and eos_token_id of model
config. It seems that this is the same bug as the HuggingFace TGI bug.
It's same bug as #29434
- **Issue:** #29431
- **Dependencies:** none
- **Twitter handle:** tell14

Example code is followings:
```python
from langchain_huggingface.llms import HuggingFacePipeline

hf = HuggingFacePipeline.from_model_id(
    model_id="meta-llama/Llama-3.2-3B-Instruct",
    task="text-generation",
    pipeline_kwargs={"max_new_tokens": 10},
)

from langchain_core.prompts import PromptTemplate

template = """Question: {question}

Answer: Let's think step by step."""
prompt = PromptTemplate.from_template(template)

chain = prompt | hf

question = "What is electroencephalography?"

print(chain.invoke({"question": question}))
```
2025-02-03 21:40:33 -05:00
..
__init__.py
test_chat_models.py partners: Fixed the procedure of initializing pad_token_id (#29500) 2025-02-03 21:40:33 -05:00
test_huggingface_pipeline.py partners/huggingface[patch]: fix HuggingFacePipeline model_id parameter (#27514) 2024-10-29 14:34:46 +00:00