<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How can we deploy a custom model in Generative AI</title>
    <link>https://community.databricks.com/t5/generative-ai/how-can-we-deploy-a-custom-model/m-p/125764#M1040</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/118624"&gt;@SandipCoder&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;I believe that you are not seeing an output because you're calling the MLflow model via a REST API endpoint. MLflow’s REST API expects the inputs to be a DataFrame-like structure, not just a single string.&lt;/P&gt;&lt;P&gt;Instead of passing this -&amp;nbsp;&lt;BR /&gt;{"inputs": "Please do the task"}&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Please pass this -&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;{
  "inputs": [
    {"question": "Please do the task"}
  ]
}&lt;/LI-CODE&gt;&lt;P&gt;Hope this helps!&lt;/P&gt;</description>
    <pubDate>Sun, 20 Jul 2025 06:57:08 GMT</pubDate>
    <dc:creator>Vidhi_Khaitan</dc:creator>
    <dc:date>2025-07-20T06:57:08Z</dc:date>
    <item>
      <title>How can we deploy a custom model</title>
      <link>https://community.databricks.com/t5/generative-ai/how-can-we-deploy-a-custom-model/m-p/87169#M485</link>
      <description>&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;Goal:&lt;/STRONG&gt;&lt;/U&gt;&lt;BR /&gt;Let's say we have a custom function with arbitrary python code . And we want to deploy that as model as we wanted to generate an API endpoint .So that that can be accessed from external applications.&lt;/P&gt;&lt;P&gt;I am attaching the below code I have tried .&lt;EM&gt;If you know any better way to do this .Please suggest.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;Sample Code I tried:&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;import mlflow&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;import mlflow.pyfunc&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;import pandas as pd&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;from mlflow.models.signature import infer_signature&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;class Model(mlflow.pyfunc.PythonModel):&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;def cust_func():&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;# Perform the SQL operation on the driver&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;sql_query_insert = f"""INSERT INTO {FULL_TABLE_NAME_FOR_LOAD} (type) SELECT 'Sandip'"""&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;spark.sql(sql_query_insert)&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;def predict(self, context, model_input):&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;cust_func()&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;return pd.DataFrame(["Done"], columns=["result"])&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;# Convert the input data to a pandas DataFrame&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;question = pd.DataFrame([{"question": "Please do your task"}])&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;with mlflow.start_run(run_name="A_run_created_from_notebook2") as run:&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;model = Model()&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;signature = infer_signature(question, model.predict(None, question))&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;mlflow.pyfunc.log_model("A_model_created_from_notebook2", python_model=model, signature=signature)&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;Error:&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;&lt;P&gt;AT API endpoint if we pass request :&lt;BR /&gt;{"inputs" : "Please do the task"}&lt;/P&gt;&lt;P&gt;Nothing is coming out.&lt;BR /&gt;Error in console : 2024/08/25 05:25:08 WARNING mlflow.pyfunc.scoring_server: If using `instances` as input key, we internally convert the data type from `records` (List[Dict]) type to `list` (Dict[str, List]) type if the data is a pandas dataframe representation. This might cause schema changes. Please use `inputs` to avoid this converesion.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 02 Sep 2024 08:24:45 GMT</pubDate>
      <guid>https://community.databricks.com/t5/generative-ai/how-can-we-deploy-a-custom-model/m-p/87169#M485</guid>
      <dc:creator>SandipCoder</dc:creator>
      <dc:date>2024-09-02T08:24:45Z</dc:date>
    </item>
    <item>
      <title>Re: How can we deploy a custom model</title>
      <link>https://community.databricks.com/t5/generative-ai/how-can-we-deploy-a-custom-model/m-p/125764#M1040</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/118624"&gt;@SandipCoder&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;I believe that you are not seeing an output because you're calling the MLflow model via a REST API endpoint. MLflow’s REST API expects the inputs to be a DataFrame-like structure, not just a single string.&lt;/P&gt;&lt;P&gt;Instead of passing this -&amp;nbsp;&lt;BR /&gt;{"inputs": "Please do the task"}&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Please pass this -&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;{
  "inputs": [
    {"question": "Please do the task"}
  ]
}&lt;/LI-CODE&gt;&lt;P&gt;Hope this helps!&lt;/P&gt;</description>
      <pubDate>Sun, 20 Jul 2025 06:57:08 GMT</pubDate>
      <guid>https://community.databricks.com/t5/generative-ai/how-can-we-deploy-a-custom-model/m-p/125764#M1040</guid>
      <dc:creator>Vidhi_Khaitan</dc:creator>
      <dc:date>2025-07-20T06:57:08Z</dc:date>
    </item>
  </channel>
</rss>

