from transformers import AutoModelForQuestionAnswering, AutoTokenizer, pipeline import…
- User
from transformers import AutoModelForQuestionAnswering, AutoTokenizer, pipeline import tensorflow as tf print(tf.version)
def GetAnswer(): # Indent the code inside the function model_name = 'timpal0l/mdeberta-v3-base-squad2' model = AutoModelForQuestionAnswering.from_pretrained(model_name) tokenizer = AutoTokenizer.from_pretrained(model_name)
qa_model = pipeline('question-answering', model=model_name, tokenizer=model_name) # download model #qa_model = pipeline("question-answering") # test model question = 'كيف يساعد رشاقة على انقاص الوزن' context= 'تطبيق رشاقة هو تطبيق رياضى يساعد المستخدمين فى انقاص الوزن من خلال اتباع نطام عذائى محدد بحتوى تطبيق رشاقة على العدبد من المميزات ومنها خاسبة السعرات وعداد الخطوات' #question="what is the advantages of rashaka" #context="rashaka is a spotive application.it contanins many advantages such as steps counter,groups" qa_response = qa_model(question = question, context = context) #print(qa_response) return qa_response # return json responseGetAnswer() # Call the function
this python code return erro WARNING:tensorflow:From C:\Users\Adminrashaqa\AppData\Local\Programs\Python\Python312\Lib\site-packages\tf_keras\src\losses.py:2976: The name tf.losses.sparse_softmax_cross_entropy is deprecated. Please use tf.compat.v1.losses.sparse_softmax_cross_entropy instead.
- Assistant
The warning you are seeing is related to an older function being used in TensorFlow. This is a compatibility warning indicating that you should update to the newer version of the function. However, it is just a warning and not an error.
If the code does not break execution and you are only seeing a warning (which seems to be the case based on your description), you can ignore this warning for now. The warning is coming because the used version of TensorFlow relies on an older method. The method will still work, but updating your code to use the latest methods is a good practice for long-term maintenance.
Here is how you can suppress these warnings if needed:
- User
c# how to run and get output from python code
- Assistant
- User
python return only part of json data
- Assistant