Forum Discussion
Azure AI Search - Tag Scoring profile on azureopenai extra_body
I created an index on Azure AI Search and connected it to Azure OpenAI using the extra_body. It works perfectly. However, I created a default scoring profile for my index, which boosts documents containing the string "zinc" in the VITAMINS field by a factor of 10.
Since doing this, I can no longer run the query that worked previously without issues. Now, the query is asking for a scoringParameter, and when I attempt to pass it, I receive an error. Here is the code that works fine when I remove the scoring function.
client.chat.completions.create(
model=os.getenv('DEPLOYMENT'),
messages=messages,
temperature=0.5,
extra_body={
"data_sources": [{
"type": "azure_search",
"parameters": {
"endpoint": os.getenv('ENDPOINT'),
"index_name": os.getenv('INDEX'),
"semantic_configuration": os.getenv('RANK'),
"query_type": "hybrid",
"in_scope": True,
"role_information": None,
"strictness": 1,
"top_n_documents": 3,
"authentication": {
"type": "api_key",
"key": os.getenv('KEY')
},
"embedding_dependency": {
"type": "deployment_name",
"deployment_name": os.getenv('ADA_VIT')
}
}
}]
}
)
However, if I activate the default scoring profile, I get the following error:
> An error occurred: Error code: 400 - {'error': 'message': 'An error occurred when calling Azure Cognitive Search: Azure Search Error: 400, message=\'Server responded with status 400. Error message: {"error":{"code":"MissingRequiredParameter","message":"Expected 1 parameter(s) but 0 were supplied.\\\\r\\\\nParameter name: scoringParameter","details":[{"code":"MissingScoringParameter","message":"Expected 1 parameter(s) but 0 were supplied."}]}}\', api-version=2024-03-01-preview\'\nCall to Azure Search instance failed.\nAPI Users: Please ensure you are using the right instance, index_name, and provide admin_key as the api_key.\n'}
**If I try to pass the scoringParameter anywhere in the extra_body**, I receive this error:
> An error occurred: Error code: 400 - {'error': {'requestid': '', 'code': 400, 'message': 'Validation error at #/data_sources/0/azure_search/parameters/scoringParameter: Extra inputs are not permitted'}}
This error is even more confusing. I’ve been looking through various resources, but none of them seem to provide a clear example of how to properly pass the scoring profile or scoring parameters in the extra_body.
Here’s how I define my scoring profile using tags:
scoring_profiles = [
ScoringProfile(
name="my-scoring-profile",
functions=[
TagScoringFunction(
field_name="VITAMINS",
boost=10.0,
parameters=TagScoringParameters(
tags_parameter="tags",
),
)
]
)
]
How to pass the scoring parameters correctly in the `extra_body` on the `client.chat.completions.create`?
PS: The only way I can get my code to work is if I delete the scoring profile or do not make it the scoring profile by default by I do want to use it.
5 Replies
- ml4uBrass Contributor
When using a custom scoring profile in Azure AI Search, you need to supply the scoring parameters in your query. Ensure that you pass the `scoringParameter` correctly in the `extra_body`. The format should be `{"scoringParameter": ["parameterName=value"]}`. Replace `parameterName` and `value` with your specific parameters. If the issue persists, double-check the scoring profile configuration and ensure it aligns with your query requirements.
- ml4uBrass Contributor
Hello,
It seems like you're encountering an issue with the `scoringParameter` when using a custom scoring profile in Azure AI Search. When you define a scoring profile, Azure Cognitive Search expects you to supply the required scoring parameters in your query. Here's what you can do:
1. **Check Scoring Profile Configuration:** Ensure that your scoring profile is correctly configured and that the `scoringParameter` is defined as expected. The parameter name in your query should match the one defined in the scoring profile.
2. **Passing Scoring Parameters:** When using the `client.chat.completions.create` method, you can pass the `scoringParameter` in the `extra_body` by including it in the `parameters` object. Make sure it aligns with the expected format and values.
3. **Error Handling:** If you encounter validation errors, double-check the parameter names and values. Ensure they are correctly formatted and match the scoring profile's requirements.
If you continue to face issues, consider reviewing the Azure Cognitive Search documentation for guidance on scoring profiles and parameter usage. Additionally, you may explore the Azure portal to test your queries and verify the scoring profile's behavior.
I hope this helps! Let me know if you have any further questions.
- saeedullahshah00Copper Contributor
It seems like the issue you're facing with Azure AI Search and scoring profiles is related to missing or mismatched scoringParameter values in your query. When you use a custom scoring profile, like boosting documents based on certain keywords, Azure expects you to pass a scoringParameter. If you're still having trouble, double-check your query parameters and ensure they match what is defined in your scoring profile. For more detailed insights into optimizing search functionalities, you can visit cartea for additional resources and solutions.
- Imadus00Copper Contributor
I suggest starting with this documentation to get familiar with scoring profiles it might help you unblock the issue.
https://learn.microsoft.com/en-us/azure/search/tutorial-rag-build-solution-maximize-relevance#update-the-index-for-semantic-ranking-and-scoring-profiles
- Imadus00Copper Contributor
I suggest starting with this documentation to get familiar with scoring profiles — it might help you unblock the issue.
https://learn.microsoft.com/en-us/azure/search/tutorial-rag-build-solution-maximize-relevance?source=recommendations#update-the-index-for-semantic-ranking-and-scoring-profiles