<?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: Load the HF pipeline in databricks in Generative AI</title>
    <link>https://community.databricks.com/t5/generative-ai/load-the-hf-pipeline-in-databricks/m-p/136398#M1292</link>
    <description>&lt;P&gt;&lt;SPAN&gt;Hi&amp;nbsp;&lt;/SPAN&gt;&lt;A style="background-color: #ffffff;" target="_blank" rel="noopener"&gt;@Mahsa&lt;/A&gt;, can you use the local disk as a&amp;nbsp;&lt;SPAN&gt;cache instead of a volume?&lt;/SPAN&gt;&amp;nbsp;It should work. Please see below&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;%pip install -U "transformers==4.44.2" "huggingface_hub&amp;gt;=0.20.0" accelerate datasets evaluate torch safetensors
dbutils.library.restartPython()


from transformers import pipeline

sentiment_classifier = pipeline(
    task="text-classification",
    model="nickwong64/bert-base-uncased-poems-sentiment",
    trust_remote_code=True,
    model_kwargs={'cache_dir': '/local_disk0/tmp/hf_cache'}
)
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 28 Oct 2025 12:47:16 GMT</pubDate>
    <dc:creator>dkushari</dc:creator>
    <dc:date>2025-10-28T12:47:16Z</dc:date>
    <item>
      <title>Load the HF pipeline in databricks</title>
      <link>https://community.databricks.com/t5/generative-ai/load-the-hf-pipeline-in-databricks/m-p/136221#M1286</link>
      <description>&lt;P&gt;Hi all,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a question about the integration of HF in Databricks.&lt;/P&gt;&lt;P&gt;I'm struggling to save the models and datasets:&lt;BR /&gt;&lt;BR /&gt;For instance, for the code below, I got this error:&lt;SPAN class=""&gt;ValueError: &lt;SPAN&gt;Could not load model nickwong64/bert-base-uncased-poems-sentiment with any of the following classes: (&amp;lt;class 'transformers.models.auto.modeling_auto.AutoModelForSequenceClassification'&amp;gt;, &amp;lt;class 'transformers.models.bert.modeling_bert.BertForSequenceClassification'&amp;gt;). See the original errors:&lt;BR /&gt;Does anyone know how I can solve this issue?&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;from transformers import pipeline

sentiment_classifier = pipeline(
    task="text-classification",
    model="nickwong64/bert-base-uncased-poems-sentiment",
    model_kwargs={'cache_dir': '/Volumes/dsa_development/belgium_data/model_dir/hf_cache'}
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Oct 2025 15:12:43 GMT</pubDate>
      <guid>https://community.databricks.com/t5/generative-ai/load-the-hf-pipeline-in-databricks/m-p/136221#M1286</guid>
      <dc:creator>Mahsa</dc:creator>
      <dc:date>2025-10-27T15:12:43Z</dc:date>
    </item>
    <item>
      <title>Re: Load the HF pipeline in databricks</title>
      <link>https://community.databricks.com/t5/generative-ai/load-the-hf-pipeline-in-databricks/m-p/136398#M1292</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Hi&amp;nbsp;&lt;/SPAN&gt;&lt;A style="background-color: #ffffff;" target="_blank" rel="noopener"&gt;@Mahsa&lt;/A&gt;, can you use the local disk as a&amp;nbsp;&lt;SPAN&gt;cache instead of a volume?&lt;/SPAN&gt;&amp;nbsp;It should work. Please see below&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;%pip install -U "transformers==4.44.2" "huggingface_hub&amp;gt;=0.20.0" accelerate datasets evaluate torch safetensors
dbutils.library.restartPython()


from transformers import pipeline

sentiment_classifier = pipeline(
    task="text-classification",
    model="nickwong64/bert-base-uncased-poems-sentiment",
    trust_remote_code=True,
    model_kwargs={'cache_dir': '/local_disk0/tmp/hf_cache'}
)
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Oct 2025 12:47:16 GMT</pubDate>
      <guid>https://community.databricks.com/t5/generative-ai/load-the-hf-pipeline-in-databricks/m-p/136398#M1292</guid>
      <dc:creator>dkushari</dc:creator>
      <dc:date>2025-10-28T12:47:16Z</dc:date>
    </item>
    <item>
      <title>Re: Load the HF pipeline in databricks</title>
      <link>https://community.databricks.com/t5/generative-ai/load-the-hf-pipeline-in-databricks/m-p/136504#M1295</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The error happens because the model "nickwong64/bert-base-uncased-poems-sentiment" isn’t correctly registered as a SequenceClassification model in Hugging Face. You can try:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;&lt;P&gt;&lt;STRONG&gt;Use AutoModelForSequenceClassification explicitly:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;DIV class=""&gt;&lt;SPAN&gt;&lt;SPAN&gt;&lt;SPAN class=""&gt;from transformers &lt;SPAN class=""&gt;import AutoModelForSequenceClassification, AutoTokenizer, pipeline model = AutoModelForSequenceClassification.from_pretrained( &lt;SPAN class=""&gt;"nickwong64/bert-base-uncased-poems-sentiment", cache_dir=&lt;SPAN class=""&gt;"/Volumes/dsa_development/belgium_data/model_dir/hf_cache" ) tokenizer = AutoTokenizer.from_pretrained( &lt;SPAN class=""&gt;"nickwong64/bert-base-uncased-poems-sentiment", cache_dir=&lt;SPAN class=""&gt;"/Volumes/dsa_development/belgium_data/model_dir/hf_cache" ) sentiment_classifier = pipeline( &lt;SPAN class=""&gt;"text-classification", model=model, tokenizer=tokenizer )&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;PRE&gt;&amp;nbsp;&lt;/PRE&gt;&lt;OL&gt;&lt;LI&gt;&lt;P&gt;&lt;STRONG&gt;Check model card: Make sure the model actually supports "text-classification"/SequenceClassification. Some HF models are only trained as AutoModel and need a wrapper for classification.&lt;/STRONG&gt;&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;&lt;STRONG&gt;Environment path: Ensure Databricks can access the specified cache_dir and it’s mounted correctly.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;This approach explicitly loads the model and tokenizer and usually resolves the “Could not load model” issue in Databricks.&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/LI&gt;&lt;/OL&gt;</description>
      <pubDate>Wed, 29 Oct 2025 06:30:46 GMT</pubDate>
      <guid>https://community.databricks.com/t5/generative-ai/load-the-hf-pipeline-in-databricks/m-p/136504#M1295</guid>
      <dc:creator>Thompson2345</dc:creator>
      <dc:date>2025-10-29T06:30:46Z</dc:date>
    </item>
  </channel>
</rss>

