Aplikasi ini menggunakan LLM (Large Language Model) GPT-4o yang diakses melalui OpenAI API untuk menghasilkan teks berdasarkan input pengguna. Input pengguna digunakan untuk mengambil informasi yang relevan dari database dan kemudian informasi yang diambil digunakan untuk menghasilkan teks. Pendekatan ini menggabungkan kekuatan transformator dan akses ke dokumen sumber.
Dalam aplikasi khusus ini, database lebih dari 1000 situs web dicari untuk informasi terkait orang tertentu. Tantangan sebenarnya di sini adalah orang yang dicari "Michał Żarnecki" muncul dalam 2 konteks berbeda sebagai 2 orang berbeda dengan nama yang sama. Tujuannya tidak hanya untuk menemukan informasi spesifik tetapi juga memahami konteksnya dan menghindari kesalahan seperti mencampurkan informasi tentang 2 orang berbeda dengan nama yang sama.
Saya menjelaskan konsep yang digunakan dalam aplikasi ini dengan detail lebih lanjut di artikel di medium.com https://medium.com/@michalzarnecki88/a-guide-to-using-llm-retrieval-augmented-generasi-with-php-3bff25ce6616
Untuk pengaturan, Anda harus menginstal Docker dan Docker Compose terlebih dahulu https://docs.docker.com/compose/install/
Jalankan di CLI: cd app/src && composer install
Atur model bahasa - pilih dari opsi di bawah ini: opsi dengan OpenAI API
"A" dengan model gratis melalui ollama API3 lokal
"B" dengan API OpenAI
Opsi B lebih sederhana dan membutuhkan lebih sedikit sumber daya CPU dan RAM, tetapi Anda memerlukan kunci API OpenAI https://platform.openai.com/settings/profile?tab=api-keys
Opsi A memerlukan lebih banyak sumber daya CPU dan RAM, tetapi Anda dapat menjalankannya itu secara lokal menggunakan API ollama. Untuk opsi ini ada baiknya memiliki GPU.
Ikuti petunjuk untuk opsi pilihan A atau B di bawah ini:
Jika Anda ingin mengatur ollama secara lokal, silakan gunakan petunjuk di bagian bawah file ini, tetapi jika menggunakan buruh pelabuhan, hal itu tidak diperlukan.
*Ollama menyediakan API lokal yang melayani LLM: "Siapkan dan jalankan model bahasa besar." https://ollama.com/
docker-compose up
*PETUNJUK: Skrip perlu mengubah dokumen sumber terlebih dahulu yang dapat memakan waktu bahkan 30 menit. Jika Anda ingin menghemat waktu, cukup hapus sebagian dokumen dari app/src/documents.
Tunggu hingga penyiapan kontainer selesai - Anda akan melihat di log konsol:
php-app | Loaded documents complete
php-app | Postgres is ready - executing command
php-app | [Sat Nov 02 11:32:28.365214 2024] [core:notice] [pid 1:tid 1] AH00094: Command line: 'apache2 -D FOREGROUND'
Anda dapat menggunakan aplikasi sebagai API dengan menggunakan permintaan seperti di bawah ini:
Opsi A ollama:
curl -d '{"prompt":"what is result of 2+2?"}' -H "Content-Type: application/json" -X POST http://127.0.0.1:2037/processOllama.php?api
Opsi B OpenAI GPT:
curl -d '{"prompt":"what is result of 2+2?"}' -H "Content-Type: application/json" -X POST http://127.0.0.1:2037/processGpt.php?api
Jalankan docker interaktif docker exec -it php-app sh
Jalankan di CLI: php minicli rag
Ajukan pertanyaan
##### INPUT:
What is the result of 2 + 2?
##### RESPONSE:
The result of 2 + 2 is 4.
##### INPUT:
what is specialization of Michał Żarnecki based on his website content
##### RESPONSE:
Michał Żarnecki is a programmer and lecturer specializing in several key areas related to modern software development and data-driven technologies.
His expertise includes:
1. **Programming Languages**: Python, PHP, JavaScript.
2. **AI and Machine Learning**: Designing systems and solutions related to artificial intelligence and machine learning.
3. **Data Mining and Big Data**: Extracting valuable insights from large datasets.
4. **Natural Language Processing (NLP)**: Working on systems that understand and generate human language.
5. **Software Development Frameworks**: Utilizing various tools and frameworks such as Streamlit, TensorFlow, PyTorch, and langchain.
6. **Database Systems**: Implementing and working with databases like PostgreSQL, Elasticsearch, Neo4j, and others.
His portfolio highlights projects such as an AI chatbot for analyzing company documents and a self-driving vehicle based on TensorFlow and Raspberry Pi.
Additionally, he has contributed to conferences and created e-learning courses focused on machine learning, underscoring his dual role as a developer and educator.
##### INPUT:
Is Michał Żarnecki programmer the same person as Michał Żarnecki audio engineer?
##### RESPONSE:
Based on the information provided, it appears that Michał Żarnecki the programmer and Michał Żarnecki the audio engineer are not the same person.
Here’s why:
1. **Fields of Expertise**:
- Michał Żarnecki, the audio engineer, was a well-known operator and reżyser dźwięku (sound director) in Poland, with notable contributions to the Polish film industry, as mentioned in the Wikipedia excerpt.
- Michal Żarnecki, the programmer, has a portfolio focused on programming in Python, PHP, and JavaScript, with projects related to AI, machine learning, data mining, and software development.
2. **Lifespan**:
- Michał Żarnecki the audio engineer was born on November 12, 1946, and passed away on November 21, 2016.
- The projects listed in Michał Żarnecki the programmer’s portfolio date from 2014 to 2016, which would be conflicting if he had passed away in 2016 and was actively working in those years.
3. **Occupational Focus**:
- The audio engineer has a career documented in film sound engineering and education.
- The programmer’s career is centered around software development, mobile applications, ERP systems, and consulting in technology.
Given the distinct differences in their professional domains, timelines, and expertise, it is highly unlikely that they are the same individual
Konsep dasar:
Detail lebih lanjut untuk kutu buku:
Untuk mempercepat pemuatan dokumen atau menggunakan lebih banyak dokumen untuk pengambilan yang lebih baik, manipulasi nilai $skipFirstN di app/src/service/DocumentLoader.php:20
Setelah perubahan pada skrip PHP, bangun kembali buruh pelabuhan dengan perintah:
docker-compose rm
docker rmi -f php-rag
docker-compose up
situs web yang digunakan untuk mengisi database vektor berasal dari kumpulan data "Klasifikasi Situs Web" di Kaggle penulis: Hetul Mehta tautan: https://www.kaggle.com/datasets/hetulmehta/website-classification?resource=download
artikel/repositori terkait:
https://medium.com/mlearning-ai/create-a-chatbot-in-python-with-langchain-and-rag-85bfba8c62d2
https://github.com/Krisseck/php-rag
https://ollama.com/download
ollama pull llama3:latest
ollama pull mxbai-embed-large
ollama list
NAME ID SIZE MODIFIED
mxbai-embed-large:latest 468836162de7 669 MB 7 seconds ago
llama3:latest 365c0bd3c000 4.7 GB 17 seconds ago
ollama serve
app/src/loadDocuments.php
(default) Harap beri tahu saya jika Anda menemukan masalah atau hal yang perlu diperbaiki. Anda dapat menghubungi saya di alamat email [email protected]. Jangan ragu untuk melaporkan bug dan mengusulkan peningkatan dalam permintaan tarik.