StarCoderBase results in HuggingChat vs API

Hello,

I’m trying to generate Python code using the StarCoderBase model. I get decent results via HuggingChat and the results there are pretty decent.

Here’s my code:

from huggingface_hub.inference_api import InferenceApi

import os
from dotenv import load_dotenv

load_dotenv()
hfkey = os.getenv("HUGGING_FACE_API_KEY")

inference = InferenceApi(repo_id="bigcode/starcoderbase", token=hfkey)

x = inference(inputs="I have a pandas dataframe, df, with 'latitude' and 'longitude' columns. Please provide an algorithm to cluster these points.")
print(x)

Here’s my result:

[{'generated_text': "I have a pandas dataframe, df, with 'latitude' and 'longitude' columns. Please provide an algorithm to cluster these points.\n\n# +\n# Your code here\n# -\n\n# ## 2.2"}]

When I submit the same request (i.e., “I have a pandas dataframe, df, with ‘latitude’ and ‘longitude’ columns. Please provide an algorithm to cluster these points.”) to HuggingChat, I get a much better response: HuggingChat

Could someone let me know what I’m doing wrong? I thought the results would be similar via these two approaches.

Thanks,
Wojciech