- ज़्यादातर कंपनियों के पास भीतर मूल्यवान डेटा होता है
- analytics data जिससे पता चलता है कि ग्राहक product के साथ कैसे interact करते हैं
- product के भीतर हुए कार्यों के audit logs, जिनसे यह समझा जा सकता है कि कोई feature कब activate हुआ
- छोटी startup के पास भी उपयोगी डेटा होता है
- support tickets के ज़रिए यह पता लगाया जा सकता है कि product के किन हिस्सों पर सबसे ज़्यादा ध्यान देने की ज़रूरत है, और इनमें feature requests भी शामिल होती हैं
- LLM (large language model) से पहले डेटा से insights निकालना मुश्किल था
- अपना खुद का model train करना पड़ता था, जिसमें feature engineering, NLP, model selection, और सबसे कठिन training data इकट्ठा करना शामिल था
- अब यह काम एक साधारण prompt से किया जा सकता है
- उदाहरण prompt: "निम्नलिखित tickets को इन categories में classify करें: Uptime, Security, Bug, Feature Request, Other"
- नतीजे में एक simple classifier बन जाता है, जो थोड़े-बहुत tweaks के साथ भी ठीक-ठाक performance देता है
- Streamlit का उपयोग करके ऐसा आंतरिक टूल आसानी से बनाया जा सकता है, जिसमें कोई भी व्यक्ति dataset पर LLM लागू करके प्रयोग कर सके
क्या बनाया जाएगा
- उपयोगकर्ता ये काम कर सकेगा
- login
- prompt लिखना: ticket classification system के लिए
- कुछ sample data पर prompt test करना और output देखना, जिसमें errors भी शामिल हों
- prompt को save करना ताकि दूसरे लोग भी उसका उपयोग कर सकें
Streamlit का संक्षिप्त परिचय
- Streamlit data applications को तेज़ी से बनाने के लिए एक बेहतरीन टूल है
- Streamlit में बहुत कम code से application लिखी जा सकती है
import streamlit as st
prompt = st.text_area(
"Prompt to test (use {text} to indicate where the text should be inserted):",
"This is an example prompt:\\n\\n{text}",
)
prompt_with_data = f"{prompt}".format(
text="`Example data to be placed into prompt`"
)
st.write(prompt_with_data)
- कोड execution का परिणाम: Streamlit अपने-आप एक interactive frontend बना देता है
- जब उपयोगकर्ता
text_area में prompt text अपडेट करता है, तो बाकी Python code अपने-आप फिर से run हो जाता है
Streamlit की ताकत
- Streamlit dashboard जैसे interactive tools बनाने के लिए बहुत शक्तिशाली है
- विभिन्न components उपलब्ध हैं: Pandas dataframe को table के रूप में render किया जा सकता है या button से action trigger किया जा सकता है
- external data loading, secrets management, और data caching utilities साथ मिलते हैं, जिससे data के साथ interaction और भी शक्तिशाली हो जाता है
चरण 1: डेटा लोड और विज़ुअलाइज़ करना
- Streamlit का उपयोग करके hard-coded data लोड किया जाता है और उसे table के रूप में render किया जाता है
.streamlit/secrets.toml फ़ाइल के ज़रिए Streamlit को बताया जाता है कि PostgreSQL database से कैसे connect करना है
psycopg2-binary install करके load_data_sample() function को update किया जाता है ताकि PostgreSQL से data लोड हो सके
- Streamlit Snowflake और Google Sheets जैसे कई data sources से connect कर सकता है
- caching के लिए
st.cache_resource आम तौर पर connection पर और st.cache_data महंगे query results पर उपयोग होता है
चरण 2: prompt के साथ डेटा चलाना
- उपयोगकर्ता से prompt लेकर उसे loaded data पर लागू किया जाता है
- prompt को
{"urgent": false, "categories": ["CategoryA", "CategoryB"]} फ़ॉर्मेट में valid JSON output करना चाहिए
- dataframe को transform करके
urgent, categories, और error (यदि error हो) columns जोड़े जाते हैं
- समय और लागत बचाने के लिए OpenAI calls को cache किया जाता है
- prompt को data पर फिर से चलाने के लिए एक button जोड़ा जाता है
चरण 3: authentication जोड़ना
- PropelAuth का उपयोग करके Streamlit में authentication जोड़ी जाती है
propelauth.py फ़ाइल बनाकर auth object export किया जाता है
- script के ऊपर उपयोगकर्ता को load किया जाता है या script execution रोक दी जाती है
- data query में user ID का उपयोग करके केवल वही data दिखाया जा सकता है, जिसके लिए access permission हो
चरण 4: prompt save करना
- उपयोगकर्ता को prompt save करने देने के लिए एक button जोड़ा जाता है
- database connection लोड करके prompt को
prompts table में insert किया जाता है
- prompt save करने के लिए user ID और prompt को parameters के रूप में पास किया जाता है
1 टिप्पणियां
मैंने 2020 में Streamlit - Python कोड से आसानी से कस्टम ML टूल बनाना के रूप में इसका संक्षिप्त परिचय दिया था, और 2022 में Snowflake ने Streamlit को $800M में अधिग्रहित किया।
कुछ समय पहले Streamlit का उपयोग करके बनाया गया एक टूल Show GN में भी एक बार आया था।
MP3 Tag Editor (Python Streamlit +FastAPI) on Docker