Gemini Nano के एक्सपेरिमेंटल वर्शन का ऐक्सेस पाना

Gemini Nano को एक्सपेरिमेंट के तौर पर ऐक्सेस करने की सुविधा, उन डेवलपर के लिए डिज़ाइन की गई है जो डिवाइस पर काम करने वाले एआई की नई सुविधाओं की मदद से, अपने ऐप्लिकेशन को बेहतर बनाना चाहते हैं. इस गाइड में, Google AI Edge SDK का इस्तेमाल करके, अपने ऐप्लिकेशन में Gemini Nano को आज़माने के बारे में जानकारी दी गई है.

ये शर्तें, Google के प्रॉडक्ट इस्तेमाल करने और Gemini Nano के एक्सपेरिमेंटल ऐक्सेस वाले प्रोग्राम में शामिल होने पर लागू होती हैं.

सैंपल ऐप्लिकेशन डाउनलोड करना

अगर आपको तैयार किए गए डेमो के साथ-साथ काम करना है, तो GitHub पर हमारा सैंपल ऐप्लिकेशन देखें.

ज़रूरी शर्तें

Gemini Nano को आज़माने के लिए, आपके पास Pixel 9 सीरीज़ का डिवाइस होना चाहिए. आगे बढ़ने से पहले, पक्का करें कि आपके पास एक डिवाइस हो. साथ ही, आपने सिर्फ़ उस खाते से लॉग इन किया हो जिसका इस्तेमाल आपको टेस्टिंग के लिए करना है.

  1. aicore-experimental Google group में शामिल हों
  2. Android AICore के टेस्टिंग प्रोग्राम में ऑप्ट इन करना

इन चरणों को पूरा करने के बाद, Play Store पर (ऐप्लिकेशन और डिवाइस मैनेज करें में जाकर) ऐप्लिकेशन का नाम "Android AICore" से बदलकर "Android AICore (Beta)" हो जाना चाहिए.

APK अपडेट करना और बाइनरी डाउनलोड करना

  1. AICore APK को अपडेट करें:
    1. सबसे ऊपर दाईं ओर, प्रोफ़ाइल आइकॉन पर टैप करें.
    2. ऐप्लिकेशन और डिवाइस मैनेज करें > मैनेज करें पर टैप करें
    3. Android AICore पर टैप करें
    4. अगर कोई अपडेट उपलब्ध है, तो अपडेट करें पर टैप करें
  2. Private Compute Service APK को अपडेट करें:
    1. सबसे ऊपर दाईं ओर, प्रोफ़ाइल आइकॉन पर टैप करें.
    2. ऐप्लिकेशन और डिवाइस मैनेज करें > मैनेज करें पर टैप करें
    3. Private Compute Services पर टैप करें
    4. अगर कोई अपडेट उपलब्ध है, तो अपडेट करें पर टैप करें
    5. इस ऐप्लिकेशन के बारे में जानकारी टैब में जाकर, वर्शन देखें. साथ ही, पुष्टि करें कि ऐप्लिकेशन का वर्शन 1.0.release.658389993 या उसके बाद का हो
  3. अपने डिवाइस को रीस्टार्ट करें और कुछ मिनट इंतज़ार करें, ताकि टेस्ट के लिए रजिस्टर करने का असर दिख सके
  4. Play Store में AICore के APK वर्शन की जांच करें. इसके लिए, "इस ऐप्लिकेशन के बारे में" टैब पर जाएं. इससे पुष्टि करें कि यह 0.thirdpartyeap से शुरू होता है

gradle को कॉन्फ़िगर करना

अपने build.gradle कॉन्फ़िगरेशन में, डिपेंडेंसी ब्लॉक में यह जानकारी जोड़ें:


implementation("com.google.ai.edge.aicore:aicore:0.0.1-exp01")

अपने build.gradle कॉन्फ़िगरेशन में, एसडीके के टारगेट का कम से कम लेवल 31 पर सेट करें:

defaultConfig {
    ...
    minSdk = 31
    ...
}

AICore SDK डाउनलोड करना और अनुमान लगाना

एक GenerationConfig ऑब्जेक्ट बनाएं. इसमें ऐसे पैरामीटर होते हैं जिनकी मदद से, मॉडल के अनुमान लगाने के तरीके के लिए प्रॉपर्टी को पसंद के मुताबिक बनाया जा सकता है.

पैरामीटर में ये शामिल हैं:

  • टेंपरेचर: इससे जवाब में यादृच्छिकता को कंट्रोल किया जाता है. इसकी वैल्यू जितनी ज़्यादा होगी, जवाब उतना ही अलग होगा
  • टॉप K: सबसे ज़्यादा रैंक वाले कितने टोकन इस्तेमाल किए जाने हैं
  • उम्मीदवारों की संख्या: जवाबों की ज़्यादा से ज़्यादा संख्या
  • ज़्यादा से ज़्यादा आउटपुट टोकन: जवाब की लंबाई
  • Worker Executor: वह ExecutorService जिस पर बैकग्राउंड टास्क चलाने चाहिए
  • Callback Executor: वह Executor जिस पर कॉलबैक शुरू किए जाने चाहिए

Kotlin

val generationConfig = generationConfig {
  context = ApplicationProvider.getApplicationContext() // required
  temperature = 0.2f
  topK = 16
  maxOutputTokens = 256
}

Java

GenerationConfig.Builder configBuilder = GenerationConfig.Companion.builder();
    configBuilder.setContext(context);
    configBuilder.setTemperature(0.2f);
    configBuilder.setTopK(16);
    configBuilder.setMaxOutputTokens(256);

ज़रूरी नहीं है कि downloadCallback एट्रिब्यूट की वैल्यू दी जाए. यह एक कॉलबैक फ़ंक्शन है, जिसका इस्तेमाल मॉडल डाउनलोड करने के लिए किया जाता है. वापस लाए गए मैसेज का इस्तेमाल, डीबग करने के लिए किया जाता है.

जनरेशन और डाउनलोड करने के लिए, पहले से बनाए गए कॉन्फ़िगरेशन के साथ GenerativeModel ऑब्जेक्ट बनाएं.

Kotlin

val downloadConfig = DownloadConfig(downloadCallback)
val generativeModel = GenerativeModel(
   generationConfig = generationConfig,
   downloadConfig = downloadConfig // optional
)

Java

GenerativeModel generativeModel = new GenerativeModel(
   generationConfig,
   downloadConfig = DownloadConfig(downloadCallback) // optional
);

मॉडल की मदद से अनुमान लगाएं और अपना प्रॉम्प्ट पास करें. GenerativeModel.generateContent() एक सस्पेंड फ़ंक्शन है. इसलिए, हमें यह पक्का करना होगा कि इसे लॉन्च करने के लिए, यह सही कोरूटीन स्कोप में हो.

Kotlin

scope.launch {
  // Single string input prompt
  val input = "I want you to act as an English proofreader. I will provide you
    texts, and I would like you to review them for any spelling, grammar, or
    punctuation errors. Once you have finished reviewing the text, provide me
    with any necessary corrections or suggestions for improving the text: These
    arent the droids your looking for."
  val response = generativeModel.generateContent(input)
  print(response.text)

  // Or multiple strings as input
  val response = generativeModel.generateContent(
  content {
    text("I want you to act as an English proofreader. I will provide you texts
      and I would like you to review them for any spelling, grammar, or
      punctuation errors.")
    text("Once you have finished reviewing the text, provide me with any
      necessary corrections or suggestions for improving the text:")
    text("These arent the droids your looking for.")
    }
  )
  print(response.text)
}

Java

Futures.addCallback(
    String input = "I want you to act as an English proofreader. I will
    provide you texts, and I would like you to review them for any
    spelling, grammar, or punctuation errors. Once you have finished
    reviewing the text, provide me with any necessary corrections or
    suggestions for improving the text:
    These aren't the droids you're looking for."
    generativeModelFutures.generateContent(input),
    new FutureCallback<GenerateContentResponse>() {
      @Override
      public void onSuccess(GenerateContentResponse result) {
        // generation successful
      }

      @Override
      public void onFailure(Throwable t) {
        // generation failed
      }
    },
    ContextCompat.getMainExecutor(this));

अगर आपको Google AI Edge SDK के बारे में कोई सुझाव/राय देनी है या शिकायत करनी है या हमारी टीम को कोई अन्य सुझाव/राय देनी है या शिकायत करनी है, तो टिकट सबमिट करें.

प्रॉम्प्ट के बारे में सलाह

प्रॉम्प्ट डिज़ाइन, ऐसे प्रॉम्प्ट बनाने की प्रोसेस है जिनसे लैंग्वेज मॉडल से सबसे सही जवाब मिल सके. अच्छे स्ट्रक्चर वाले प्रॉम्प्ट लिखना, भाषा मॉडल से सटीक और अच्छी क्वालिटी के जवाब पाने के लिए ज़रूरी है. हमने Gemini Nano के कुछ सामान्य इस्तेमाल के उदाहरण दिए हैं, ताकि आप इसका इस्तेमाल शुरू कर सकें. ज़्यादा जानकारी के लिए, Gemini को प्रॉम्प्ट देने की रणनीतियां देखें.

फिर से लिखने के लिए:

I want you to act as an English proofreader. I will provide you texts, and I
would like you to review them for any spelling, grammar, or punctuation errors.
Once you have finished reviewing the text, provide me with any necessary
corrections or suggestions for improving the text: These arent the droids your
looking for

स्मार्ट जवाब की सुविधा के इस्तेमाल के उदाहरण:

Prompt: Predict up to 5 emojis as a response to a text chat message. The output
should only include emojis.

input: The new visual design is blowing my mind 🤯
output: ➕,💘, ❤‍🔥

input: Well that looks great regardless
output: 💗,🪄

input: Unfortunately this won't work
output: 💔,😔

input: sounds good, I'll look into that
output: 🙏,👍

input: 10hr cut of jeff goldblum laughing URL
output: 😂,💀,⚰️

input: Woo! Launch time!
Output:

खास जानकारी पाने के लिए:

Summarize this text as bullet points of key information.
Text: A quantum computer exploits quantum mechanical phenomena to perform
  calculations exponentially faster than any modern traditional computer. At
  very tiny scales, physical matter acts as both particles and as waves, and
  quantum computing uses specialized hardware to leverage this behavior. The
  operating principles of quantum devices are beyond the scope of classical
  physics. When deployed at scale, quantum computers could be used in a wide
  variety of applications such as: in cybersecurity to break existing encryption
  methods while helping researchers create new ones, in meteorology to develop
  better weather forecasting etc. However, the current state-of-the-art quantum
  computers are still largely experimental and impractical.