Menu
Menu
DaniWeb
Log In
Sign Up
Read
Contribute
Meet
Search
Search
About 1,000 results for
def
- Page 1
Image Analysis Using Llama 3.2 Vision Instruct Model
Programming
Computer Science
6 Days Ago
by usmanmalik57
… the image and suggests potential prevention measures. ```python
def
analyze_image(query, image_url): response = llama3_2_model_client.chat_completion( model…answers the query related to both images. ```python
def
analyze_multiple_images(query, image1_url, image2_url): response = llama3_2_model_client.…
Fine-tuning OpenAI Vision Models for Visual Question-Answering
Programming
Computer Science
3 Weeks Ago
by usmanmalik57
…the `predicted_answers` list to calculate the model's accuracy. ```python
def
make_predictions(dataframe, model_id, system_role): actual_answers = [] predicted_answers = [] #…values in corresponding items of the two lists. ```python
def
count_matching_answers(answers, predictions): count = 0 # Iterate through…
Qwen vs Llama - Who is winning the Open Source LLM Race
Programming
Computer Science
2 Weeks Ago
by usmanmalik57
… as parameters and returns the model client response. ```python
def
generate_summary(model, system_role, user_query): response = model.chat_completion( …and returns ROUGE scores. ```python # Function to calculate ROUGE scores
def
calculate_rouge(reference, candidate): scorer = rouge_scorer.RougeScorer(['rouge1', 'rouge2',…
RAG with LangChain and Hugging Face Serverless Inference API
Programming
Computer Science
1 Week Ago
by usmanmalik57
… verify the response from the PDF document. ```python
def
generate_response(query): response = retrieval_chain.invoke({"input"… that generates chatbot responses with memory. ```python chat_history = []
def
generate_response_with_memory(query): response = retrieval_chain.invoke({ "chat_history": …
Re: Qwen vs Llama - Who is winning the Open Source LLM Race
Programming
Computer Science
2 Weeks Ago
by Brandon_38
The competition between Qwen and Llama in the open-source LLM race is fascinating to follow! Both models bring unique strengths to the table, making it exciting to see which will emerge as the leader. I appreciate the ongoing innovation in this space, as it pushes the boundaries of what's possible with language models. It will be interesting to …
Extract Schema.org Data Script (Python)
Digital Media
Digital Marketing
Search Engine Strategies
2 Months Ago
by Chris Hüneke
… Function to extract Schema.org data from a given URL
def
extract_schema_data(url): response = requests.get(url) soup =… # Function to format Schema.org data for readable output
def
format_schema_data(schema_data): formatted_data = "" for data in…
How to Fine-tune the OpenAI GPT-4o Model - The Wait is Finally Over
Programming
Computer Science
2 Months Ago
by usmanmalik57
…quot; # Function to create the JSON structure for each row
def
create_json_structure(row): return { "messages": [ {"role… ROUGE2, and ROUGEL scores. ``` # Function to calculate ROUGE scores
def
calculate_rouge(reference, candidate): scorer = rouge_scorer.RougeScorer(['rouge1', 'rouge2', '…
Text Classification and Summarization with Qwen 2.5 Model From Hugging Face
Programming
Computer Science
1 Month Ago
by usmanmalik57
…the actual tweet sentiments and display the model accuracy. ```python
def
find_sentiment(dataset): tweets_list = dataset["text"].tolist() … scores for comparison. ```python # Function to calculate ROUGE scores
def
calculate_rouge(reference, candidate): scorer = rouge_scorer.RougeScorer(['rouge1', 'rouge2',…
Comparison of Fine-tuning GPT-4o mini vs GPT-3.5 for Text Classification
Programming
Computer Science
2 Months Ago
by usmanmalik57
…" # Function to create the JSON structure for each row
def
create_json_structure(row): return { "messages": [ {"role": "… by comparing the actual and predicted sentiments of the tweets. ```
def
find_sentiment(client, model, dataset): tweets_list = dataset["text"].…
Extract and Count Reviews/AggregateRating Script (Python)
Digital Media
Digital Marketing
Search Engine Strategies
2 Months Ago
by Chris Hüneke
… get the total number of reviews from a category URL
def
get_total_reviews(url): total_reviews = 0 page_number = 1 review_pattern = re.compile(r… to process the sitemap and extract reviews for each category
def
main(): sitemap_url = 'https://example.com/category-sitemap.xml' # Replace with…
GPT-4o Snapshot vs Meta Llama 3.1 70b for Zero-Shot Text Summarization
Programming
Computer Science
2 Months Ago
by usmanmalik57
… = os.environ.get('OPENAI_API_KEY'), ) # Function to calculate ROUGE scores
def
calculate_rouge(reference, candidate): scorer = rouge_scorer.RougeScorer(['rouge1', 'rouge2', 'rougeL… it on the completeness, conciseness, and coherence criteria. ```
def
llm_evaluate_summary(article, summary): prompt = f"""Evaluate…
Enhancing RAG Functionalities using Tools and Agents in LangChain
Programming
Computer Science
2 Months Ago
by usmanmalik57
…method as you previously did and return the response. ``` @tool
def
WikipediaSearch(search_term: str): """ Use this tool to… can have multiple session IDs if you want multiple conversations. ```
def
generate_response(query): response = agent_with_chat_history.invoke( {"input": query}, …
Image Generation with State of the Art Flux Diffusion Models
Programming
Computer Science
1 Month Ago
by usmanmalik57
… use this function to generate images in your code. ```python
def
generate_image_from_text(prompt, image_name): image = pipe( prompt, height=1024, … for the modified image and modifies the passed image. ```python
def
modify_image(image_url, prompt, image_name): init_image = load_image(url) images = mod_pipe(…
Extracting Structured Outputs from LLMs in LangChain
Programming
Computer Science
1 Month Ago
by usmanmalik57
… using the following script. ``` # Function to generate the formatted article
def
format_articles(df, num_articles=10): formatted_articles = "" for i in…
How to flush network buffers in Apple / Python
Programming
Software Development
1 Month Ago
by TSC_Chazz
… socket # Import socket module and JSON parser module import json
def
social_init(): global social1_resps, social2_resps, social3_resps host = "test.mydomain.com…
Re: Fine-Tuning OpenAI Whisper Model for Audio Classification in PyTorch
Programming
Computer Science
1 Month Ago
by Duane_4
This is an interesting and useful post. I believe there is a typo in the 7th code block relating to train/val/test split. The second line should read: val_df, test_df = train_test_split(temp_df, test_size=0.5, random_state=42) The whole point of temp_df in the first line was to separate out 30% for val/test; the second line splits that to …
Re: Fine-Tuning OpenAI Whisper Model for Audio Classification in PyTorch
Programming
Computer Science
1 Month Ago
by meyerrluanna
The post gives a really clear, step-by-step guide on how to fine-tune the OpenAI Whisper model for audio classification. Its great how it covers everything from preparing the dataset to using tools for feature extraction and model training .This is definitely worth checking out, The explanations are practical, and the code snippets make it easy to …
Re: Extract Schema.org Data Script (Python)
Digital Media
Digital Marketing
Search Engine Strategies
2 Months Ago
by Chris Hüneke
Sorry, i got that wrong. I can't post scripts in Digital Marketing section, right?
Re: Telephone directory program in python
Programming
Software Development
1 Month Ago
by Mansour_4
To save the name and phone use i/O FILE EX, Fi= open ("filename.text")
Re: Extract and Count Reviews/AggregateRating Script (Python)
Digital Media
Digital Marketing
Search Engine Strategies
2 Months Ago
by Chris Hüneke
Sorry, i got that wrong. I can't post scripts in Digital Marketing section, right?
Re: Extract and Count Reviews/AggregateRating Script (Python)
Digital Media
Digital Marketing
Search Engine Strategies
2 Months Ago
by Dani
No, just in Web Development, but you can use the seo tag.
Re: Extract and Count Reviews/AggregateRating Script (Python)
Digital Media
Digital Marketing
Search Engine Strategies
2 Months Ago
by abuislam
Great script! It’s a practical solution for aggregating review counts across categories. Automating the process for accurate Schema.org markup can definitely improve SEO and visibility. Thanks for sharing!
Re: Image Generation with State of the Art Flux Diffusion Models
Programming
Computer Science
1 Month Ago
by autowrecking
Impressive Thanks for sharing.
Re: How to flush network buffers in Apple / Python
Programming
Software Development
1 Month Ago
by rproffitt
How long have you been asking this question? I see priors at over 5 months and the second question I have for you is what do you consider helpful? While I'd rewrite this another way I won't rewrite it for you. You are the author and must support your app for as long as you see fit. I see nothing wrong with the usual open socket, send data, close…
Re: How to flush network buffers in Apple / Python
Programming
Software Development
1 Month Ago
by TSC_Chazz
I asked it once on one other forum, five months ago. Yes, this is a very low priority issue; if I can't get it working, I'll simply leave it as is and Apple users will be SOL. And what I would consider helpful is specifically what I'm asking: how do I get the data to actually leave the Apple machine without closing the connection?
Re: How to flush network buffers in Apple / Python
Programming
Software Development
1 Month Ago
by rproffitt
We ran into this on other platforms and worked around it. Sorry, no magic() call I know of, just had to rewrite. TCP turned out to be the incorrect choice for our needs but hey you can google "tcp force send" to see if any of those ideas work. Again, I don't know of any magic() here. Only that we had to rewrite. Read https://…
def, plg explain little bit more about this
Programming
Web Development
10 Years Ago
by !@#$
def
y we need this in ruby i am beginner of ruby i donot understand what is use of
def
with out this we make code also i think according to my knowledge it is reserve word
Re: def, plg explain little bit more about this
Programming
Web Development
10 Years Ago
by sepp2k
You need the `
def
` keyword to define methods in Ruby. The reason that you need a keyword for this is that the creator of Ruby decided that was the most convenient syntax for method definitions.
def __init__ problem
Programming
Software Development
14 Years Ago
by ChargrO
…by itself but i want to implement
def
hello and
def
toggle into
def
__init__(self, master=None), at the… would like the code to stay inside the
def
__init__ because i will be adding other functions …this. [CODE] from Tkinter import * class Application(Frame):
def
__init__(self, master=None): self.master = master=None …
Re: def __init__ problem
Programming
Software Development
14 Years Ago
by ChargrO
…out here?? [CODE] from Tkinter import * class Application(Frame):
def
__init__(self, master=None): self.master = master self.menubar =…self) submenu=Menu(menubar,tearoff=0)
def
hello(self): print "hello !"
def
toggle(self): if submenu.entrycget(0,&…
1
2
3
17
Next
Last
Search
Search
Forum Categories
Hardware/Software
Recommended Topics
Programming
Recommended Topics
Digital Media
Recommended Topics
Community Center
Recommended Topics
Latest Content
Newest Topics
Latest Topics
Latest Posts
Latest Comments
Top Tags
Topics Feed
Social
Forums
Top Members
Meet People
Community Functions
DaniWeb Premium
Newsletter Archive
Markdown Syntax
Community Rules
Developer APIs
Connect API
Forum API Docs
Tools
SEO Backlink Checker
Legal
Terms of Service
Privacy Policy
FAQ
About Us
Advertise
Contact Us
© 2024 DaniWeb® LLC