[GH-ISSUE #2353] sentiment analysis works interactively, but it doesn't via API #63403

Closed
opened 2026-05-03 13:21:19 -05:00 by GiteaMirror · 3 comments
Owner

Originally created by @Blu-Eagle on GitHub (Feb 4, 2024).
Original GitHub issue: https://github.com/ollama/ollama/issues/2353

Originally assigned to: @bmizerany on GitHub.

when I use LLAMA2 asking for a sentiment analysis of a text, it works, while if I try to do the same using the API I do not get the same result, just a sort of summary of the text.

the code I use for the api is the following:

`
url = "http://localhost:11434/api/generate"

payload = {
"model": "llama2",
"prompt": prompt,
"system": comando,
"stream": False
}
payload_json = json.dumps(payload)
headers = {"Content-Type": "application/json"}
response = requests.post(url, data=payload_json, headers=headers)
`
where
prompt: is the text
comando: is the request: "Make the sentiment analysis of the text provided"

the same request and the same text are given interactively and only interactively I get a sentiment analysis.
I use LLAMA2 7B.

thanks for any suggestions.
Giuseppe

Originally created by @Blu-Eagle on GitHub (Feb 4, 2024). Original GitHub issue: https://github.com/ollama/ollama/issues/2353 Originally assigned to: @bmizerany on GitHub. when I use LLAMA2 asking for a sentiment analysis of a text, it works, while if I try to do the same using the API I do not get the same result, just a sort of summary of the text. the code I use for the api is the following: ` url = "http://localhost:11434/api/generate" payload = { "model": "llama2", "prompt": prompt, "system": comando, "stream": False } payload_json = json.dumps(payload) headers = {"Content-Type": "application/json"} response = requests.post(url, data=payload_json, headers=headers) ` where prompt: is the text comando: is the request: "Make the sentiment analysis of the text provided" the same request and the same text are given interactively and only interactively I get a sentiment analysis. I use LLAMA2 7B. thanks for any suggestions. Giuseppe
GiteaMirror added the needs more info label 2026-05-03 13:21:19 -05:00
Author
Owner

@ahsan123322 commented on GitHub (Feb 5, 2024):

are you using custom API?

<!-- gh-comment-id:1926289988 --> @ahsan123322 commented on GitHub (Feb 5, 2024): are you using custom API?
Author
Owner

@bmizerany commented on GitHub (Mar 12, 2024):

@Blu-Eagle llama2 is a general purpose model so it will likely respond with some length hard to parse response. Have you tried tuning your prompt, temperature, tokens expected, etc to coerce it into responding more tersely?

<!-- gh-comment-id:1989681884 --> @bmizerany commented on GitHub (Mar 12, 2024): @Blu-Eagle llama2 is a general purpose model so it will likely respond with some length hard to parse response. Have you tried tuning your prompt, temperature, tokens expected, etc to coerce it into responding more tersely?
Author
Owner

@bmizerany commented on GitHub (Mar 12, 2024):

Closing for now. Please reopen with a complete code example and environment information (including ollama version) if the issue persists.

<!-- gh-comment-id:1992552047 --> @bmizerany commented on GitHub (Mar 12, 2024): Closing for now. Please reopen with a complete code example and environment information (including ollama version) if the issue persists.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#63403