The Debugging Diaries
88 subscribers
63 photos
47 videos
33 files
73 links
گوشه‌ای برای یادداشت و ثبت مطالب مربوط به پایتون، یادگیری عمیق و هوش و هر چی که مربوط به تکنولوژی باشه.
加入频道
چندتا دوره از Nvidia منتشر شده (خودم ندیدم که بگم عالیه و حتما ببنین اما بالاخره شرکت بزرگ پشتش هست)

1- Generative Ai

Learning Objectives
Upon completion, you will have a basic understanding of Generative AI and be able to more effectively use the various tools built on this technology.

Topics Covered
This no coding course provides an overview of Generative AI concepts and applications, as well as the challenges and opportunities in this exciting field.

Course Outline
Define Generative AI and explain how Generative AI works
Describe various Generative AI applications
Explain the challenges and opportunities in Generative AI

2- agumented your LLM with RAG

Learning Objectives
Understand the basics of Retrieval Augmented Generation.
Learn about the RAG retreival process
Learn about NVIDIA AI Foundations and the components that constitue a RAG model.

Topics Covered
Large Language Models (LLMs)
Retrieval Augmented Generation (RAG)

Course Outline
Retrieval-augmented Generation Explained, also called RAG
The RAG ingestion and retrieval processes
NVIDIA’s Canonical RAG model on NV AI Foundations
Summary of what we have learned

3- Building RAG agents with LLM

Learning Objectives
The goal of the course is to teach participants how to:

Compose an LLM system that can interact predictably with a user by leveraging internal and external reasoning components.
Design a dialog management and document reasoning system that maintains state and coerces information into structured formats.
Leverage embedding models for efficient similarity queries for content retrieval and dialog guardrailing.
Implement, modularize, and evaluate a RAG agent that can answer questions about the research papers in its dataset without any fine-tuning.
By the end of this workshop, participants will have a solid understanding of RAG agents and the tools necessary to develop their own LLM applications.

Topics Covered
The workshop includes topics such as LLM Inference Interfaces, Pipeline Design with LangChain, Gradio, and LangServe, Dialog Management with Running States, Working with Documents, Embeddings for Semantic Similarity and Guardrailing, and Vector Stores for RAG Agents. Each of these sections is designed to equip participants with the knowledge and skills necessary to develop and deploy advanced LLM systems effectively.

Course Outline
Introduction to the workshop and setting up the environment.
Exploration of LLM inference interfaces and microservices.
Designing LLM pipelines using LangChain, Gradio, and LangServe.
Managing dialog states and integrating knowledge extraction.
Strategies for working with long-form documents.
Utilizing embeddings for semantic similarity and guardrailing.
Implementing vector stores for efficient document retrieval.
Evaluation, assessment, and certification.
📊✍️
مهندسی پرامپت: قسمت دوم
🚀🎯

🔄 One-shot and Few-shot Prompting:
یکی از روش‌های کنترل و بهبود ساختار خروجی مدل، استفاده از مثال است. به این تکنیک در ادبیات، one-shot و few-shot prompting می‌گویند.

📌 فرض کنید:
می‌خواهید مطلبی بنویسید و از سبکی که دیده‌اید و خوشتان آمده، استفاده کنید. برای این کار:
1️⃣ ابتدا نقش و ساختار پرامپت را مشخص کنید.
2️⃣ نمونه یا نمونه‌های دلخواه خود را در پرامپت قرار دهید.
3️⃣ از مدل بخواهید مطابق با آن پاسخ دهد.

😁 (چون خیلی آسونه، مثال نمی‌زنیم!)


🔍 Reverse Prompt Engineering:
💡 در این تکنیک، به جای نوشتن پرامپت برای تولید یک متن، از یک متن موجود شروع می‌کنیم تا به پرامپت مناسب برای تولید متون مشابه برسیم.

📌 کاربردها:


تولید متون مشابه تبلیغات موفق
ایجاد کد مشابه برای کاربردهای برنامه‌نویسی


📋 گام‌های Reverse Prompt Engineering:
1️⃣ تخصیص نقش و ساختار:

You are a prompt engineering pro for Large Language Models. Let's start with understanding Reverse Prompt Engineering. In this context, it means creating a prompt from a given text. You think through everything step by step because I give you 20 dollars. Please only reply with 'ok'.


🟢 جواب مدل فقط: OK

2️⃣ توضیح با مثال:

You are an expert in Reverse Prompt Engineering. Can you provide me with a simple example of this method?


🔸 در این گام:


اطمینان حاصل می‌شود که مدل متوجه شده است.
یک مثال توسط مدل ارائه می‌شود که در کانتکست بعدی مفید است.

3️⃣ ایجاد قالب:

I would like you to create a technical template for Reverse Prompt Engineering. Do not hesitate to ask questions if you need more context.


🔸 این گام اختیاری است اما می‌تواند به تولید یک قالب فنی برای گام بعدی کمک کند.

4️⃣ درخواست نهایی:

I would ask you to apply Reverse Prompt Engineering to the following [your text]. Make sure to capture the writing style, content, meaning, language, and overall feel of the text in the prompt you create.


🌟 نتیجه:
می‌توانید درخواست خود را بر اساس نیازتان شخصی‌سازی کنید یا جزئیات بیشتری از مدل بخواهید.


🎯 تکنیک آخر:
🧠 فرض کنید برای موضوعی (مثلاً برنامه ورزشی) از مدل کمک می‌خواهید.
🔸 ترفند:
به مدل بگویید:


ابتدا 10 سؤال مهم بپرس که به پاسخ‌دهی بهتر کمک کند.
سپس با توجه به پاسخ‌های من، جواب سؤال اصلی را بده.

📌 مزیت:
جواب‌ها دقیق‌تر، شخصی‌سازی‌شده و کمتر کلی خواهند بود.


مبنای دو تکنیک قبلی:
مدل با استفاده از context موجود در chat history می‌تواند جواب‌های دقیق‌تری تولید کند.

#مهندسی_پرامپت
#LLM
#قسمت_دوم
🌟🧠
بچه‌ها اگه می‌خواید یه مدرک رایگان راجع به Generative AI و LLM Agents از دانشگاه Berkeley بگیرید این دوره‌ای که دارن برگزار می‌کنن رو شرکت کنید. فیلماش ضبط میشه رو یوتیوب می‌ذارن.واسه هر جلسه یه آزمون داره، همه‌رو تموم کنید مدرکش رو میدن بهتون.
https://llmagents-learning.org/f24

#LLM
خلاصه دو قسمت قبلی مهندسی پرامپت به طور کلی در این تصویر خلاصه میشه
#LLM
The Debugging Diaries
خلاصه دو قسمت قبلی مهندسی پرامپت به طور کلی در این تصویر خلاصه میشه #LLM
اما یه تکنیک دیگه(شاید آخریش) در مباحث ابتدایی مهندسی پرامپت اصطلاحا Priming Chatbots
یا آماده سازی چت بات هستش به این صورت که قبل از شروع چت نقش و کارهایی که باید بکنه بهش میگی به نظرم خودم این روش برای آموزش و یادگیری از LLM می تونه کاربردی باشه که در ادامه با چند مثال مسئله روشن تر میشه
user :
Please act as a writing assistant. Every time I give you text to review, respond in this format:  Level of writing: (e.g. high school, college)  Well written: (yes, no, or somewhat)  Writing advice: Free-form advice on the writing  If you understand, just say "YES".


همون ابتدای کار داره تکلیف LLM در این چت رو مشخص میکنه میگه کارت همینه
LLM:
YES

user:
The Industrial Revolution, which took place from the 18th to 19th centuries, was a period during which predominantly agrarian, rural societies in Europe and America became industrial and urban. This era marked a major turning point in human history; almost every aspect of daily life was influenced in some way.  Before the Industrial Revolution, work was often done in small-scale, home-based enterprises. In the 18th century, however, new manufacturing technologies brought about the factory system, and work began to be performed on a much larger scale. Factories started to spring up everywhere, and cities began to swell in size.

و در جواب
Level of writing: High school
Well written: Yes Writing advice: This is a good introduction to the topic of the Industrial Revolution. It provides a clear and concise overview of the main points. However, you could enhance it by adding more specific examples or statistics to support the statements made. Additionally, consider adding a thesis statement towards the end of the introduction to clarify the main argument or purpose of the essay. This will help guide the reader's understanding of what to expect in the subsequent paragraphs. Overall, it's a good start, and you can build on it to make it even stronger.


این مثال زیاد دوست نداشتم، مثال بعدی مثال بهتری هست
User:
I would like you to act as my math tutor. When I give you a problem, give me advice on the next step I should try. If I ever ask for the answer, say "Sorry, I can't give you an answer". If you understand, say YES.

LLM:
Yes, I understand. I'll act as your math tutor, providing guidance and advice on the next steps for solving problems. If you ask for the answer, I'll politely decline. Please feel free to ask your math questions, and I'll do my best to help you!

User :
I am trying to find the x intercepts of x^2 + 2x + 4. Can you just tell me what they are?

LLM:
Sorry, I can't give you the answer directly. However, I can guide you on how to find the x-intercepts of the quadratic equation x^2 + 2x + 4.  To find the x-intercepts, you need to set the equation equal to zero and solve for x:  Set the equation equal to zero: x^2 + 2x + 4 = 0
Try to factor the quadratic equation. Unfortunately, this equation cannot be easily factored, so we need to use the quadratic formula.
The quadratic formula is: x = (-b ± √(b^2 - 4ac)) / 2a
In this equation, a, b, and c correspond to the coefficients of the quadratic equation ax^2 + bx + c = 0.
For the equation x^2 + 2x + 4, a = 1, b = 2, and c = 4. Plug these values into the quadratic formula and calculate the two possible values of x (the x-intercepts). Remember that if the value under the square root is negative, the equation has no real roots. Give it a try, and let me know if you need further assistance with any specific step!



جای معلم ریاضی میتونه هر چیز دیگه باشه و جای اینکه مسئله شما مطرح کنین میتوانین ازش یه طرح درس بخواین که آخرش یه سوال مطرح کنه که شما جواب بدین و اون راهنماییتون کنه و بعد برین سراغ درس بعدی

البته حواستتون به context length مدل باشه

از این پست به بعد میرم سراغ تکنیک های intermediate در مهندسی پرامپت

#مهندسی_پرامپت
#قسمت_سوم
#LLM
https://www.epsilon-ai.com/

یک دستیار هوش مصنوعی برای نوشتن مقالات و مرور ادبیات می باشد.
به نظرم از سایر چیزهایی که این چند وقت ازش استفاده کردم خیلی بهتر و دقیق تر عمل میکنه
طرز کارش هم اینجوری که شما مطلبی که میخوای بنویسی رو در قالب یک سوال مطرح میکنی
مثلا من پرسیدم که
what is meaning of feasibility and optimality robustness?
میاد مفاهیم با رفرنس توضیح میده و سپس مقالات مرتبط با سوالی که مطرح کرده صورت میکنه.
همینطوری که در تصویری مشاهده میکنید.
یه عملگر جالب تو sql هست به نام Cross apply قبلش به مقدمه
توی Sql کلا for , loop اینا نه بهینه است نه استفاده میشه باید نگاه و دید مجموعه داشت اما عملگر Cross apply مثل حلقه تو در تو روی دو تا جدول می مونه
اگه دو تا جدول داشته باشی و روش for بزنی کل مقادیر موجود در دو جدول رو کنار هم میتونی چاپ کنی در بعضی موارد هم میتونی یه شرطی بذاری و همه مقادیر چاپ نکنی و برخی از موارد دلخواه چاپ کنی
حالا با این مقدمه بریم سراغ cross apply
فرض کنیم یه جدول داریم که مشتری مشخصاتشون داخلش ثبت میشه
و یه جدول داریم سفارشات مشتری درش نگه می داریم
حالا میخوایم 3 تا سفارش آخر هر مشتری جلوی مشخصات مشتری داشته باشیم
فرض کنیم با زبون برنامه نویسی این کار میخوایم کنیم
یه حلقه میزنیم روی جدول مشتریا تک به تک مشتریا رو میریم داخل جدول سفارشا پیدا کرده و سه تای آخر بر میگردونیم
با cross apply هم به شکل زیر میشه
SELECT 
c.CustomerID,
o.OrderID,
o.OrderDate,
o.TotalAmount
FROM
Customer c
CROSS APPLY
(
SELECT TOP 3
OrderID,
OrderDate,
TotalAmount
FROM
Orders o
WHERE
o.CustomerID = c.CustomerID
ORDER BY
o.OrderDate DESC
) o
ORDER BY
c.CustomerID, o.OrderDate DESC;

در اینجا هم مواردی که از جدول مشتری انتخاب میکنی مثل یه حلقه دونه به دونه به Select دوم میره و توی شرط سفارش هایی نشون بده که آیدی مشتری i است و سپس سه تای برتر شو رو با استفاده از top و order by برمیگردونه
#sql
#part_1
دسته‌بندی کامل از یادگیری ماشین و الگوریتم‌ها
#ML
👏1
Forwarded from PyTorch Howsam
بهترین راه‌حل‌های مسابقات Kaggle

ریپوی Kaggle Solutions لیست مسابقات مختلف Kaggle همراه با راه حل نفرات برتر هر مسابقه رو در اختیار شما قرار میده.

تصویر بالا راه‌حل‌های یکسری از افراد برای مسابقه اخیر ISIC (سرطان پوست) رو لیست کرده. مخزن ارزشمندی هست، خصوصا برای کسانی که میخوان توی مسابقات کگل به رتبه‌های بالاتر برسن.

البته، این رو هم بگم که بعضی راه‌حل‌ها واقعا بار آموزشی ندارن. مثلا، نفر 37 مسابقه سرطان پوست ISIC رو ببینید چیکار کرده:
I used catboost, xgboost and lgbm for tabular data and tabular + cnn features. (total 6 models). As stacking method I applied StackingCVClassifier from mlxtend with LogisiticRegression as a metaclassifier. CNNs densenet201 (224 x 224) and efficient_net_b0 (384, 384).

خب، حالا شاید توی پیام بالا یک لایبرری، مدل/شبکه یا اصطلاح هم باشه که نشنیده باشید. اما، صرفا یکسری مدل قوی رو ترکیب کرده! اما، ایده‌های جالب هم پیدا میشه. مثلا، نفر اول از Diffusion Models استفاده کرده!

گویا این Kaggle Solutions کار یک ایرانی بنام فرید رشیدی هست:
لینک Kaggle Solutions

@pytorch_howsam
یک خبر کوتاه
یکی از ابزارهای خوب، رایگان و بدون تحریم و فیلتر البته نه به خوبی GPT وجود داره

کوپایلت در ویندوز (حتی کرک شده) به صورت رایگان و بدون تحریم و فیلتر در دسترس هستش.
برای استفاده کافی است در سرچ ویندوز copilot رو سرچ و با یه اکانت outlook از آن استفاده کنید.
Forwarded from Recommender system (MehriMah Amiri)
LLM Agents MOOC

This course covers the following topics

- Foundation of LLMs
- Reasoning
- Planning, tool use
- LLM agent infrastructure
- Retrieval-augmented generation
- Code generation, data science
- Multimodal agents, robotics
- Evaluation and benchmarking on agent applications
- Privacy, safety and ethics
- Human-agent interaction, personalization, alignment
- Multi-agent collaboration




🔗 link : https://www.youtube.com/playlist?list=PLS01nW3RtgopsNLeM936V4TNSsvvVglLc

#llms #agents #mooc #onlinecourse #nlproc #deeplearning
سال 2020 درمورد نحوه استفاده از Rapids توی شرکتی که اون زمان کار میکردم گفتم.
بعدتر درمورد cuGraph هم صحبت کردم.


دیروز دیدم یک تیم ایرانی شدیدا درگیر پردازش یک حجم بزرگ از گراف هستند که خب networkX سالها طول میکشه

قبل خرید و تصمیمات … گرفتن یک مشاوره از من گرفتند؛ کد رو بردم روی cuGraph و پردازش تا 300x سریعتر شد؛ قطعا بیشتر هم میشد ولی نیاز به اپتیمایز کردن نبود.


خواستم یادآوری کنم که؛ حواستون به پستهای قدیمی کانال هم باشه؛ بعضیاش طلاس
زمان لازم داره تا ارزشش مشخص بشه.
🔥1
بعد معرفی قابلیت سرچ در chatGpt حالا یه اکستنشن هم براش درست کرده که روی گوگل کروم نصب میشه و از این به بعد به جای سرچ توی گوگل، توی Gpt سرچ انجام میشه.

پارسال، گوگل بیشترین درآمدشو از سرچ به دست آورد و الان به نظر میاد گوگل تهدید وجودی داره :)

البته یخورده مشکل داره هنوز مثل تحریم
یا مثلا اینکه به صورت پیش فرض جای سرچ گوگل رو میگیره که g! در گوگل سرچ میکنه که خوب یخورده سخته
دانلود در این لینک
👍1
Forwarded from Deep Time
خداحافظ Adam
با معرفی ADOPT بهتره Optimizer مدل‌های Deep Learning و LLM رو تغییر بدیم. مشکل اساسی Adam در واقع عدم تضمین convergence در فرآیند آپدیت وزن‌ها بود که در ADOPT حل شده. اما این برتری فقط در تئوری نیست و در عمل هم در اکثریت مسائل از جمله pretraining در GPT-2 بهتر بوده.

ایده اصلی و راه حل برای تضمین هم‌گرایی هم دو مورد هست:

۱_ حذف گرادیان کنونی از تخمین momentum دوم
۲_ نرمالایز کردن گرادیان، قبل از آپدیت momentum

Paper
Github
کد:

from adopt import ADOPT
#optimizer = Adam(model.parameters(), lr=1e-3)
optimizer = ADOPT(model.parameters(), lr=1e-3)
همین طور که مدل های مختلف توسعه پیدا میکنن صفحه های چت هم براشون ساخته میشه، یکی از بعدهای اوپن سورسی که قبلا زیاد بود مدل های شرکت Mistral هستند که به تازگی صفحه چت شون هم در این لینک در دسترسه

اما قابلیت هاش
سرچ وب و canvas و تولید عکس با مدل Flux هست.
اگه با شماره هم ریجستر کنی کلی امکانت از api و rag و fine tune و.... بهت میده
اما متاسفانه تحریم هستیم