# Hey I am facing issues

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhey-i-am-facing-issues%2F108177%3E%5C
**Category:** Beginners\
**Created:** [September 23, 2024, 5:46pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhey-i-am-facing-issues%2F108177 "2024-09-23T17:46:53Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![vatsal04](https://avatars.discourse-cdn.com/v4/letter/v/278dde/32.png) [@vatsal04](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fvatsal04)%5C
**Post date:** [September 23, 2024, 5:46pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhey-i-am-facing-issues%2F108177%2F1 "2024-09-23T17:46:53Z")

</div>

pls help

 ![Screenshot 2024-09-23 230048](https://us1.discourse-cdn.com/hellohellohello/original/3X/5/2/520a00885a56446a18774c1ac02a19d0ecfa9b65.png)

---

<div class="post-metadata">

**Author:** ![vatsal04](https://avatars.discourse-cdn.com/v4/letter/v/278dde/32.png) [@vatsal04](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fvatsal04)%5C
**Post date:** [September 23, 2024, 5:47pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhey-i-am-facing-issues%2F108177%2F2 "2024-09-23T17:47:53Z")

</div>

Here is the starting of the code

 ![Screenshot 2024-09-23 230009](https://us1.discourse-cdn.com/hellohellohello/original/3X/8/9/894e0ff802e900fd0697efb8d178b51d7388a090.png)

---

<div class="post-metadata">

**Author:** ![vatsal04](https://avatars.discourse-cdn.com/v4/letter/v/278dde/32.png) [@vatsal04](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fvatsal04)%5C
**Post date:** [September 23, 2024, 5:48pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhey-i-am-facing-issues%2F108177%2F3 "2024-09-23T17:48:25Z")

</div>

And the code after it

 ![Screenshot 2024-09-23 230027](https://us1.discourse-cdn.com/hellohellohello/original/3X/6/b/6bc35dc996a190a39e06366da1ba11b44d7cc4cd.png)

---

<div class="post-metadata">

**Author:** ![vatsal04](https://avatars.discourse-cdn.com/v4/letter/v/278dde/32.png) [@vatsal04](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fvatsal04)%5C
**Post date:** [September 23, 2024, 7:17pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhey-i-am-facing-issues%2F108177%2F4 "2024-09-23T19:17:30Z")

</div>

Update tried using try except block to know about the error .

 ![Screenshot 2024-09-24 004614](https://us1.discourse-cdn.com/hellohellohello/original/3X/6/5/657583e0319ed37898126df0b512f8eaffe3502f.png)

---

<div class="post-metadata">

**Author:** ![John6666](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/john6666/32/27664_2.png) [@John6666](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FJohn6666)%5C
**Post date:** [September 24, 2024, 2:02am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhey-i-am-facing-issues%2F108177%2F5 "2024-09-24T02:02:20Z")

</div>

I just had a quick look and **your HF token is in your uploaded image** before I take care of the problem.  
Please **go remove the token leaked** first. Once erased, the token is no longer needed, so it doesn’t matter if it has leaked.

Also, it would be easier for me to respond if you could write in the text.  
You can quote the code in a nice way by enclosing it in ```. like this,

```py
import os

```

> **[Markdown Code Block: Including Code In .md Files - Markdown Land](https://markdown.land/markdown-code-block)**
>
> Learn three ways to insert a Markdown code block in your document, including a method that supports syntax highlighting.

---

<div class="post-metadata">

**Author:** ![John6666](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/john6666/32/27664_2.png) [@John6666](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FJohn6666)%5C
**Post date:** [September 24, 2024, 2:19am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhey-i-am-facing-issues%2F108177%2F6 "2024-09-24T02:19:34Z")

</div>

Probably the same problem as this one.

> **[Mandatory Hugging Face token to use HuggingFaceEndpoint ·...](https://github.com/langchain-ai/langchain/discussions/20740)**
>
> Checked other resources I added a very descriptive title to this question. I searched the LangChain documentation with the integrated search. I used the GitHub search to find a similar question and...

> **[Login and logout](https://huggingface.co/docs/huggingface_hub/main/en/package_reference/login)**
>
> We’re on a journey to advance and democratize artificial intelligence through open source and open science.

---

<div class="post-metadata">

**Author:** ![vatsal04](https://avatars.discourse-cdn.com/v4/letter/v/278dde/32.png) [@vatsal04](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fvatsal04)%5C
**Post date:** [September 24, 2024, 3:47am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhey-i-am-facing-issues%2F108177%2F7 "2024-09-24T03:47:28Z")

</div>

I deleted the token before posting here actually .

---

<div class="post-metadata">

**Author:** ![vatsal04](https://avatars.discourse-cdn.com/v4/letter/v/278dde/32.png) [@vatsal04](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fvatsal04)%5C
**Post date:** [September 24, 2024, 4:11am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhey-i-am-facing-issues%2F108177%2F9 "2024-09-24T04:11:22Z")

</div>

![Screenshot 2024-09-24 093833](https://us1.discourse-cdn.com/hellohellohello/original/3X/8/1/812addd7cc29e9e9e1285fd40e604374896b011a.png)

```import
from langchain.prompts import PromptTemplate
from langchain.llms.huggingface_endpoint import HuggingFaceEndpoint
from langchain.schema.runnable import RunnableSequence
from huggingface_hub import login

# Set HuggingFace API token
os.environ['HUGGINGFACEHUB_API_TOKEN'] = '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'

# Define the prompt template
prompt = PromptTemplate(
    input_variables=["product"],
    template="Tell me a good company name that makes this product: {product}"
)

# Initialize the HuggingFace endpoint
llm = HuggingFaceEndpoint(repo_id='google/flan-t5-large', temperature=0, max_new_tokens=250)

# Create a runnable sequence with the prompt and LLM
chain = RunnableSequence(prompt, llm)

# Invoke the chain and handle potential errors
try:
    result = chain.invoke({'product': 'coffee'})
    print(result)
except Exception as e:
    print("Error occurred:", e)
```

---

<div class="post-metadata">

**Author:** ![John6666](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/john6666/32/27664_2.png) [@John6666](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FJohn6666)%5C
**Post date:** [September 24, 2024, 4:13am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhey-i-am-facing-issues%2F108177%2F10 "2024-09-24T04:13:11Z")

</div>

> {‘product’: ‘coffee’}

The error message is broken in the middle, but it seems to be grammatically incorrect here. Perhaps the option is obsolete or the option name is incorrect.

But here it is, no matter how you look at it…  
I wonder if the options of the other functions in the chain are broken.

---

<div class="post-metadata">

**Author:** ![vatsal04](https://avatars.discourse-cdn.com/v4/letter/v/278dde/32.png) [@vatsal04](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fvatsal04)%5C
**Post date:** [September 24, 2024, 4:22am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhey-i-am-facing-issues%2F108177%2F11 "2024-09-24T04:22:50Z")

</div>

I removed that line . But it is still showing the same error “HTTPError”.

```import
from langchain.prompts import PromptTemplate
from langchain.llms.huggingface_endpoint import HuggingFaceEndpoint
from langchain.schema.runnable import RunnableSequence
from huggingface_hub import login

# Set HuggingFace API token
os.environ['HUGGINGFACEHUB_API_TOKEN'] = 'my_api_token'

# Define the prompt template
prompt = PromptTemplate(
    input_variables=["product"],
    template="Tell me a good company name that makes this product: {product}"
)

# Initialize the HuggingFace endpoint
llm = HuggingFaceEndpoint(repo_id='google/flan-t5-large', temperature=0, max_new_tokens=250)

# Create a runnable sequence with the prompt and LLM
chain = RunnableSequence(prompt, llm)

chain.invoke('coffee')
```

---

<div class="post-metadata">

**Author:** ![John6666](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/john6666/32/27664_2.png) [@John6666](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FJohn6666)%5C
**Post date:** [September 24, 2024, 4:25am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhey-i-am-facing-issues%2F108177%2F12 "2024-09-24T04:25:19Z")

</div>

It’s an HTTPError, but the server is telling you that the request is wrong.  
This means that the function is working on the server, and the function is misinterpreting some of the options.  
I think it’s the **prompt** that’s suspicious, I think the LLM is correct.

[https://python.langchain.com/v0.2/api\_reference/core/prompts/langchain\_core.prompts.prompt.PromptTemplate.html](https://python.langchain.com/v0.2/api_reference/core/prompts/langchain_core.prompts.prompt.PromptTemplate.html)

But I don’t think there’s anything wrong with the prompt, either.

> **[Hugging Face x LangChain : A new partner package](https://huggingface.co/blog/langchain)**
>
> We’re on a journey to advance and democratize artificial intelligence through open source and open science.

I’m a little suspicious of the lack of task, because LLM can do a lot of things. Especially the ones that are closer to VLM.

```py
from langchain_huggingface import HuggingFaceEndpoint

llm = HuggingFaceEndpoint(
    repo_id="unsloth/Meta-Llama-3.1-8B-bnb-4bit", # since official one is gated,
    task="text-generation",
    max_new_tokens=100,
    do_sample=False,
)
llm.invoke("Hugging Face is")

```

Also, I think you have to set do\_sample to True for the temperature to work. Or delete temperature.

> <https://github.com/hiyouga/LLaMA-Factory/issues/2837>
>
> \### Reminder
> 
> \- \[X\] I have read the README and searched the existing issues.
> 
> \##…# Reproduction
> 
> from llmtuner import export\_model
> export\_model(dict(
> model\_name\_or\_path="NousResearch/Llama-2-7b-chat-hf",
> adapter\_name\_or\_path="/content/LLaMA-Factory/saves/LLaMA2-7B-Chat/lora/train\_2024-03-13-20-49-08",
> finetuning\_type="lora",
> template="llama2",
> export\_dir="test\_exported",
> export\_hub\_model\_id="GSalimp/TesteExport",
> ))
> 
> 
> ValueError: The generation config instance is invalid -- \`.validate()\` throws warnings and/or exceptions. Fix these issues to save the configuration.
> 
> Thrown during validation:
> \[UserWarning('\`do\_sample\` is set to \`False\`. However, \`temperature\` is set to \`0.9\` -- this flag is only used in sample-based generation modes. You should set \`do\_sample=True\` or unset \`temperature\`.'), UserWarning('\`do\_sample\` is set to \`False\`. However, \`top\_p\` is set to \`0.6\` -- this flag is only used in sample-based generation modes. You should set \`do\_sample=True\` or unset \`top\_p\`.')\]
> 
> \### Expected behavior
> 
> \_No response\_
> 
> \### System Info
> 
> \_No response\_
> 
> \### Others
> 
> \_No response\_

---

<div class="post-metadata">

**Author:** ![vatsal04](https://avatars.discourse-cdn.com/v4/letter/v/278dde/32.png) [@vatsal04](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fvatsal04)%5C
**Post date:** [September 24, 2024, 4:47am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhey-i-am-facing-issues%2F108177%2F13 "2024-09-24T04:47:38Z")

</div>

Yess the LLM model had the issue . Thank You John .

 ![Screenshot 2024-09-24 101521](https://us1.discourse-cdn.com/hellohellohello/original/3X/8/c/8c8023c0bd9070e194b5373cdf8c928369a5b26f.png)

```prompt

# Initialize the HuggingFace endpoint with correct parameters (without extra model_kwargs)
llm = HuggingFaceEndpoint(
    repo_id="meta-llama/Meta-Llama-3-8B-Instruct",
    task="text-generation",
    max_new_tokens=100,
    do_sample=False,
)
# Create a runnable sequence with the prompt and LLM
chain = RunnableSequence(prompt, llm)

chain.invoke("Hugging Face")
```

---

<div class="post-metadata">

**Author:** ![John6666](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/john6666/32/27664_2.png) [@John6666](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FJohn6666)%5C
**Post date:** [September 24, 2024, 4:48am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhey-i-am-facing-issues%2F108177%2F14 "2024-09-24T04:48:54Z")

</div>

I did it. So if I turn off temperature, maybe it will work? Also, put a task on it. The rest should be correct.

> do\_sample=False,

It’s just a default value.

---

<div class="post-metadata">

**Author:** ![vatsal04](https://avatars.discourse-cdn.com/v4/letter/v/278dde/32.png) [@vatsal04](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fvatsal04)%5C
**Post date:** [September 24, 2024, 4:52am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhey-i-am-facing-issues%2F108177%2F15 "2024-09-24T04:52:38Z")

</div>

yep it is working without adding the temperature.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/hellohellohello/original/2X/d/de4155eb4aa4108ecb32a1389d7cc37ae69f88b7.png) [@system](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fsystem)%5C
**Post date:** [September 24, 2024, 4:52pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhey-i-am-facing-issues%2F108177%2F16 "2024-09-24T16:52:47Z")

</div>

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.
