Skip to content
Notifications
Clear all

Step-by-step: Using HuggingChat to analyze open-ended survey responses at scale.

3 Posts
3 Users
0 Reactions
23 Views
(@devops_rookie_2025)
Prominent Member
Joined: 4 months ago
Posts: 467
Topic starter   [#13742]

Hi everyone! I'm diving into the world of LLMs and wanted to share my first real project using HuggingChat. I had to analyze hundreds of open-ended feedback responses from a recent internal survey, and doing it manually was impossible.

I used the `mistralai/Mixtral-8x7B-Instruct-v0.1` model via the HuggingChat API. My goal was to categorize each response by sentiment and main topic. Here's a simplified version of my Python script. It's probably basic, but it worked!

```python
import requests
import json

API_URL = "https://api-inference.huggingface.co/models/mistralai/Mixtral-8x7B-Instruct-v0.1"
headers = {"Authorization": "Bearer YOUR_HF_TOKEN"}

def query(payload):
response = requests.post(API_URL, headers=headers, json=payload)
return response.json()

survey_response = "The deployment process is too slow and needs better documentation."
prompt = f"""
Categorize the following survey feedback.
First, sentiment (Positive, Neutral, Negative).
Second, main topic (e.g., Deployment, Documentation, Performance).
Feedback: {survey_response}
"""

output = query({
"inputs": prompt,
"parameters": {"max_length": 100}
})
print(output)
```
This gave me structured data I could then process further. I'm sure there are better ways to do this (maybe batching?), so I'd love any tips from the community! How do you handle prompt engineering for batch analysis like this?



   
Quote
(@henryg78)
Estimable Member
Joined: 3 months ago
Posts: 165
 

Have you considered caching the responses or implementing a retry loop for rate limits? For hundreds of responses, your API costs could add up, and the model isn't deterministic.

Using a cheaper, specialized sentiment model first, then passing only uncertain results to Mixtral, would cut costs significantly. You might also get better consistency by structuring the output with a JSON schema in the prompt.

```python
prompt = f"""Feedback: {survey_response}nOutput JSON: {{"sentiment": "", "topic": ""}}"""
```


EXPLAIN ANALYZE


   
ReplyQuote
(@integrations_ivan)
Reputable Member
Joined: 7 months ago
Posts: 242
 

That's a solid architectural suggestion. The tiered model approach is something I've implemented for production feedback pipelines, but it introduces a new consistency problem.

If you route only uncertain responses to the more capable model, you're creating two different classification contexts. The smaller sentiment model might use a different internal mapping for topic labels than Mixtral does. When you merge the results, you could get topic category drift unless you strictly enforce the same output schema and definitions on both models.

Your JSON prompt structure is essential, but you'd need to extend it with explicit category definitions. For example:

```python
topic_definitions = "Topics: 'product_ui' = comments on interface, 'product_feature' = requests for new functions..."
prompt = f"""Use these exact categories: {topic_definitions} Feedback: {response} Output JSON: {{"sentiment": "positive|neutral|negative", "topic": ""}}"""
```

Without that, the cheaper model might label something as "usability" while Mixtral calls it "interface," and your aggregated data becomes unreliable.


Single source of truth is a myth.


   
ReplyQuote