Model Overview
This project provides an MLflow-compatible model that acts as a proxy to an external backend service. Instead of performing local machine learning inference, the model forwards user queries to a backend API and returns structured responses.
Request Format
The model expects input in JSON format following the MLflow scoring protocol.
Example Request
{
"inputs": [
{
"question": "Which documents mention institutions or universities?",
"dataset": "research_production",
"agent": "domain"
}
]
}
Field Descriptions
inputs(array) – A list of one or more query objects (each representing a single request).question(string) – The user’s natural language query.dataset(string) – Specifies which dataset to use (e.g.research_production,ai_ecosystem).agent(string) – Selects which backend agent handles the request (e.g.domain,data_exploration).
Response Format
Example Response
{
"content": {
"images": [],
"text": "Documents mentioning institutions or universities are found in Articles 37, 56, and 68."
},
"explanation": {
"code": "",
"sources": [
{
"article": "Article 37",
"page": 20,
"title": "Law on Gender Equality",
"url": "https://example.com/doc1.pdf"
}
]
}
}
Field Descriptions
-
content(object) – The main user-facing answer.text(string) – The generated natural language response.images(array) – Optional list of images related to the answer.
-
explanation(object) – Supporting details for transparency and traceability.-
code(string) – Optional code used to produce the answer (mainly for data queries). -
sources(array) – List of references backing the answer:article(string) – Referenced article or section.page(number) – Page number in the document.title(string) – Document title.url(string) – Link to the source document.
-
Architecture
Client → MLflow → ModelMapper → Model → External API
Usage
mlflow models serve -m "models:/social_policy_making_model/1" --env-manager local -p 5001
Registering running model on Databricks
Add the deployment
curl --location 'https://staging.private.tango.u-hopper.com/api/deployment' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer YOUR_TOKEN' \
--header 'Cookie: language=en-us' \
--data '{
"deployment_key":"afl-dbx_social-policy-making-model",
"registry_connector_class":"tango_shared.connectors.deployment.databricks_registry_connector.DatabricksModelRegistryConnector",
"registry_connector_init":{
"model_registry_url": "https://YOUR_DBX_INSTANCE.azuredatabricks.net/",
"tracking_server_url": "https://YOUR_DBX_INSTANCE.azuredatabricks.net/",
"tracking_server_pat": "YOUR_DBX_PAT"
},
"server_proxy_class":"tango_shared.connectors.deployment.databricks_server_proxy.DatabricksModelServerProxy",
"server_proxy_init":{
"server_proxy_url": "https://YOUR_DBX_INSTANCE.azuredatabricks.net/serving-endpoints/social_policy_making_model",
"server_proxy_pat": "YOUR_DBX_PAT"
}
}'
Add the model
curl --location 'https://staging.private.tango.u-hopper.com/api/model' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer YOUR_TOKEN' \
--header 'Cookie: language=en-us' \
--data '{
"deployment_key": "afl-dbx_social-policy-making-model",
"model_code": "social_policy_making_model_mapper",
"name": "Social Policy Making model on DBX Workspace Model Registry",
"description": "This model providing features for T5.5 Social Policy Making case study",
"version": "2",
"realtime_execution": false,
"allow_download": false,
"need_context": false,
"model_card_file_id": "YOUR_MODEL_CARD_FILEID",
"input_schema": {
"fields": [{"type": "string", "name": "question", "required": "True"},
{"type": "string", "name": "dataset", "required": "True"},
{"type": "string", "name": "agent", "required": "True"}]
},
"output_schema": {
"fields": [{"type": "string", "name": "content", "required": "True"}]
}
}'
Approve the model
curl --location --request PATCH 'https://staging.private.tango.u-hopper.com/api/model/social_policy_making_model_mapper/version/1' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer YOUR_TOKEN' \
--header 'Cookie: language=en-us' \
--data '{
"status": "APPROVED"
}'