[Gemini] gemini calculate Tokenize in Locally
ยท
๐Ÿ› ๏ธ Tools
Google VertaxAI Python SDK  gemini tokenizer๋Š” ์›๋ž˜ ๊ณต๊ฐœ๋˜์ง€ ์•Š์•„ token์„ ๊ณ„์‚ฐํ•˜๋ ค๋ฉด API๋ฅผ ์‚ฌ์šฉํ•ด์•ผ ํ•˜๋Š” ๋ฒˆ๊ฑฐ๋กœ์›€์ด ์žˆ์—ˆ๋‹ค. ๊ทธ๋ž˜์„œ Google Cloud Community์— ์งˆ๋ฌธ์„ ๋“ฑ๋กํ–ˆ๋‹ค. ์š”๋Š” tiktoken๊ณผ ๊ฐ™์ด token ๊ณ„์‚ฐ์„ local๋กœ ํ•  ์ˆ˜์žˆ๊ฒŒ ๊ณต๊ฐœํ•ด ๋‹ฌ๋ผ๋Š” ๊ฒƒ์ด์—ˆ๋‹ค. token ์ˆ˜๋ฅผ ์•Œ ์ˆ˜ ์—†์œผ๋ฉด gemini-api๋ฅผ ์‚ฌ์šฉํ•  ๋•Œ max_token์— ๋งž๊ฒŒ ๊ณ„์† ์กฐ์ •ํ•ด์•ผ ํ•˜๊ธฐ ๋•Œ๋ฌธ์— ์ˆ˜ ์ฐจ๋ก€ API๋ฅผ ์‚ฌ์šฉํ•ด์•ผ ํ•œ๋‹ค. ์ด๋Ÿฐ ๋ฌธ์ œ๋ฅผ ์˜์‹ํ–ˆ๋Š”์ง€ token ์ˆ˜๋ฅผ API๋กœ ํ™œ์šฉํ•  ์ˆ˜ ์žˆ๊ฒŒ ๊ณต๊ฐœํ–ˆ์ง€๋งŒ ๋ฌธ์ œ๋Š” ๋‘ ๋ฒˆ์˜ API ์‚ฌ์šฉ๋„ ๋งˆ์Œ์— ๋“ค์ง€ ์•Š์•˜๋‹ค.   tiktoken์œผ๋กœ OpenAI์—์„œ๋Š” tokenizer์™€ vocab์„ ๊ณต๊ฐœํ•ด ํˆฌ๋ช…ํ•˜๊ฒŒ API ๋น„์šฉ์„ ์ฒญ..
Embedding Model API ํ•œ๊ตญ์–ด Token & ๋น„์šฉ ๋น„๊ต
ยท
๐Ÿ—ฃ๏ธ Natural Language Processing
“๋Œ€ํ•œ๋ฏผ๊ตญ ๋ฒ•๋ฅ  ์ „๋ฌธ”์„ ๊ฐ€์ง€๊ณ  OpenAI(ChatGPT), GOOGLE(Gemini), Antropic(Claude), Upstage(Solar)๋ฅผ ๋Œ€์ƒ์œผ๋กœ embedding ํ›„ token ์ˆ˜๋ฅผ ๋น„๊ตํ•˜๋Š” ์‹คํ—˜์„ ์ง„ํ–‰ Goal : API๋กœ ์ œ๊ณต๋˜๋Š” LLM ์ค‘ ์–ด๋–ค ๋ชจ๋ธ์ด ํ•œ๊ตญ์–ด token์„ ๊ฐ€์žฅ ์ ๊ฒŒ ์‚ฌ์šฉํ•˜๊ณ  ๋น„์šฉ ์ €๋ ดํ•œ์ง€ ๋น„๊ต Input Text(๋Œ€ํ•œ๋ฏผ๊ตญํ—Œ๋ฒ• ์ „๋ฌธ, text length=373) ์œ ๊ตฌํ•œ ์—ญ์‚ฌ์™€ ์ „ํ†ต์— ๋น›๋‚˜๋Š” ์šฐ๋ฆฌ๋“ค ๋Œ€ํ•œ๊ตญ๋ฏผ์€ ๊ธฐ๋ฏธ ์‚ผ์ผ์šด๋™์œผ๋กœ ๋Œ€ํ•œ๋ฏผ๊ตญ์„ ๊ฑด๋ฆฝํ•˜์—ฌ ์„ธ๊ณ„์— ์„ ํฌํ•œ ์œ„๋Œ€ํ•œ ๋…๋ฆฝ์ •์‹ ์„ ๊ณ„์Šนํ•˜์—ฌ ์ด์ œ ๋ฏผ์ฃผ๋…๋ฆฝ๊ตญ๊ฐ€๋ฅผ ์žฌ๊ฑดํ•จ์— ์žˆ์–ด์„œ ์ •์˜์ธ๋„์™€ ๋™ํฌ์• ๋กœ์จ ๋ฏผ์กฑ์˜ ๋‹จ๊ฒฐ์„ ๊ณต๊ณ ํžˆ ํ•˜๋ฉฐ ๋ชจ๋“  ์‚ฌํšŒ์  ํ์Šต์„ ํƒ€ํŒŒํ•˜๊ณ  ๋ฏผ์ฃผ์ฃผ์˜์ œ์ œ๋„๋ฅผ ์ˆ˜๋ฆฝํ•˜์—ฌ ์ •์น˜, ๊ฒฝ์ œ, ์‚ฌํšŒ, ๋ฌธํ™”์˜ ๋ชจ๋“  ์˜์—ญ์— ์žˆ์–ด..
[Gemini] github action์—์„œ gemini api ์‚ฌ์šฉ์‹œ _CLOUD_SDK_MISSING_CREDENTIALS Auth Error
ยท
๐Ÿ› ๏ธ Tools
raise exceptions.DefaultCredentialsError(_CLOUD_SDK_MISSING_CREDENTIALS) google.auth.exceptions.DefaultCredentialsError: Your default credentials were not found. To set up Application Default Credentials, see https://cloud.google.com/docs/authentication/external/set-up-adc for more information. ์ธ์ฆ๋˜์ง€ ์•Š์€ IP์—์„œ ๊ตฌ๊ธ€ API(google-generativeai)๋ฅผ ์‚ฌ์šฉํ•  ๋•Œ ์ƒ๊ธฐ๋Š” ๋ฌธ์ œ ๋‘๊ฐ€์ง€ ๋ฌธ์ œ๋กœ ์ด Error๊ฐ€ ๋ฐœ์ƒํ•œ๋‹ค. ์ฒซ๋ฒˆ์งธ google-auth์˜ ๋ฒ„์ „์ด ๋‚ฎ์•„ ..
[Gemini] ValueError: The `response.parts` quick accessor only works for a single candidate, but none were returned. Check the `response.prompt_feedback` to see if the prompt was blocked.
ยท
๐Ÿ—ฃ๏ธ Natural Language Processing
ValueError: The `response.parts` quick accessor only works for a single candidate, but none were returned. Check the `response.prompt_feedback` to see if the prompt was blocked. ์›์ธ : ์ž˜๋ชป๋œ request๋กœ prompt ์‘๋‹ต์ด ์ฐจ๋‹จ๋œ case ํ˜น์€ safety setting error request ๋ณด๋‚ด๊ธฐ ์ „์— parameter๋ฅผ ๋‹ค ๊ธฐ์ž…ํ•ด์ค€๋‹ค. ํ˜„์žฌ๋กœ์„œ๋Š” max_tokens candidate_count : ์ถœ๋ ฅ ์ˆ˜ top_p : log_probabilities๋“ค์˜ argmax ๊ฐ’์„ ์—ญ์ˆœ์œผ๋กœ ์ •๋ ฌํ•œ๋’ค ๋‹จ์–ด ๋‹จ์œ„๋กœ ์žฌ๊ตฌ์„ฑ (๊ธ€๋ €๋‹ค_argmax : 0.7, ํž˜๋“ค๋‹ค_a..
๋‹คํ–ˆ๋‹ค
'Gemini' ํƒœ๊ทธ์˜ ๊ธ€ ๋ชฉ๋ก