paint-brush
Google এর PaLM API কতটা ভালো?দ্বারা@raymondcamden
1,407 পড়া
1,407 পড়া

Google এর PaLM API কতটা ভালো?

দ্বারা Raymond Camden10m2023/10/28
Read on Terminal Reader

অতিদীর্ঘ; পড়তে

যেমন, আমি অনুমান করি, গ্রহের প্রতিটি একক বিকাশকারী, আমি গত বছর বা তারও বেশি সময় ধরে GenAI-এর সাথে কিছুটা প্লাবিত হয়েছি।
featured image - Google এর PaLM API কতটা ভালো?
Raymond Camden HackerNoon profile picture
0-item
1-item

গ্রহের প্রতিটি একক বিকাশকারীর মতো, আমিও গত এক বছর বা তার বেশি সময় ধরে GenAI-এর সাথে কিছুটা প্লাবিত হয়েছি। আমি এটিকে বেশিরভাগ লোকের মতোই আকর্ষণীয় বলে মনে করি (চ্যাটজিপিটি-এর সাথে আমি কতবার বিড়াল-সম্পর্কিত রূপান্তর করেছি সে সম্পর্কে আমাকে জিজ্ঞাসা করুন) তবে এটি খেলতে মজাদার, আমি এর ব্যবহারিক দিকগুলি সম্পর্কেও অনেক চিন্তা করেছি, বিশেষ করে API এবং ইন্টিগ্রেশনের মাধ্যমে। আমি এখনও এই সব কিছুর জন্য অবিশ্বাস্যভাবে নতুন এবং, আমি স্বীকার করব, এখনও অনেক বিবরণে অস্পষ্ট, কিন্তু আমি ভেবেছিলাম যে আমি Google এর LLM, PaLM 2 এর সাথে কাজ করেছি এমন কিছু প্রাথমিক ইমপ্রেশন শেয়ার করব।


Google এর PaLM API এ এক নজর



প্রথম এবং সর্বাগ্রে, মনে রাখবেন যে PaLM API, এবং MakerSuite, যা একটি ওয়েব-ভিত্তিক ফ্রন্ট-এন্ড, এর জন্য একটি Google লগইন প্রয়োজন, এবং অন্ততপক্ষে API নিজেই অ্যাক্সেসের জন্য জিজ্ঞাসা করতে হবে। আমার জন্য, এটি চব্বিশ ঘন্টারও কম সময় নেয়, এবং আমি বিশ্বাস করি এই সময়টি এখন আরও দ্রুত কারণ Google অপেক্ষা তালিকা সঙ্কুচিত করছে৷ আমি যেমন বলেছি, আমি একটি চমত্কার দ্রুত অনুমোদন পেয়েছিলাম এবং আমি আশা করি যে বেশিরভাগ লোকের কাছে এটাই হবে, তবে YMMV।


PaLM API এবং MakerSuite-এ অ্যাক্সেস সংক্রান্ত Google-এর পক্ষ থেকে স্বাগত ইমেল


আপনি যখন MakerSuite লোড করেন, তখন আপনাকে API এর সাথে খেলা শুরু করার জন্য বিভিন্ন প্রম্পটের একটি সেট উপস্থাপন করা হয়:


MakerSuite সাইট পাঠ্য, ডেটা এবং চ্যাটের জন্য প্রম্পট দেখাচ্ছে৷


আমি যখন প্রথম এখানে আসি, তখন আমি ঠিক "টেক্সট প্রম্পট" বিকল্পে গিয়েছিলাম কারণ আমি ভেবেছিলাম যে বিকল্পগুলির মধ্যে সবচেয়ে সহজ এবং সবচেয়ে স্বীকৃত হবে। এখনই, শুরু করতে সাহায্য করার জন্য আমি সত্যিই নমুনাগুলির প্রশংসা করেছি:


টেক্সট প্রম্পের জন্য MakerSuite UI।


আমি এই প্রম্পট দিয়ে শুরু করেছি:


 Write a story about a magic cat who can only do magic when speaking in reverse. Also, their magic normally backfires in a humorous and harmless manner. The story should be appropriate for a young child.


এবং পেয়েছিলাম:


 Once upon a time, there was a magic cat named Mr. Mistoffelees. He was a very special cat, because he could only do magic when he spoke in reverse. One day, Mr. Mistoffelees was walking down the street when he saw a little girl crying. "What's wrong?" he asked. "I lost my doll," the little girl said. "I've looked everywhere for it, but I can't find it." Mr. Mistoffelees thought for a moment. "I can help you find your doll," he said. "But I can only do it if you speak in reverse." The little girl was confused, but she agreed. "Okay," she said. "I'll try." "Dolla," the little girl said. "Lose, I did." Mr. Mistoffelees smiled. "Your doll is under the bed," he said. The little girl ran to her house and looked under the bed. Sure enough, there was her doll. She picked it up and hugged it tightly. "Thank you," she said to Mr. Mistoffelees. "You're a very kind cat." "You're welcome," Mr. Mistoffelees said. "I'm always happy to help." Mr. Mistoffelees continued to use his magic to help people. He made lost children find their way home, he helped people find their lost pets, and he even helped people find their lost keys. But sometimes, his magic would backfire in a humorous way. One day, Mr. Mistoffelees was trying to help a woman find her lost car. He said the magic words in reverse, but instead of making the car appear, it made the woman's hair stand on end. The woman laughed so hard that she forgot all about her car. Another time, Mr. Mistoffelees was trying to help a man get a job. He said the magic words in reverse, but instead of getting the man a job, it made the man's tie fall off. The man laughed so hard that he forgot all about his interview. Mr. Mistoffelees' magic was always a lot of fun, and it always made people happy. He was a very special cat, and he used his magic to make the world a better place.


আমি চ্যাটজিপিটি এবং অন্যান্য পরিষেবাগুলি থেকে যা আশা করি তার সাথে এটি অনেকটা সমান, যদিও আমি বিড়ালের বানান দেখে কিছুটা অবাক হয়েছিলাম। কৌতূহলী লোকদের জন্য, এটি মেফিস্টোফিলিসের একটি ভুল বানান বলে মনে হচ্ছে, যদিও এটি যদি "fleas" এর উপর একটি শ্লেষের জন্য যাচ্ছিল, তবে এটি বেশ দুর্দান্ত।

আমি এখনই যেটির দিকে অভিকর্ষিত হয়েছিলাম তা হল "কোড পান" বোতামের শীর্ষে। এটিতে ক্লিক করা চারটি অনন্য বিকল্প নিয়ে আসে:


cuRL, JavaScript, JSON, এবং Python-এ কোড নমুনা


যদিও এটি অদ্ভুতভাবে কোডে প্রতিক্রিয়া অন্তর্ভুক্ত করেছে, আমি একেবারেই পছন্দ করেছি যে এটি কত সহজ ছিল! আমি ম্যানুয়ালি প্রতিক্রিয়া মুছে ফেলার পরে এখানে জাভাস্ক্রিপ্ট আছে:


 const { TextServiceClient } = require("@google-ai/generativelanguage"); const { GoogleAuth } = require("google-auth-library"); const MODEL_NAME = "models/text-bison-001"; const API_KEY = "YOUR API KEY"; const client = new TextServiceClient({ authClient: new GoogleAuth().fromAPIKey(API_KEY), }); const promptString = `Write a story about a magic cat who can only do magic when speaking in reverse. Also, their magic normally backfires in a humorous and harmless manner. The story should be appropriate for a young child.`; const stopSequences = []; client.generateText({ // required, which model to use to generate the result model: MODEL_NAME, // optional, 0.0 always uses the highest-probability result temperature: 0.7, // optional, how many candidate results to generate candidateCount: 1, // optional, number of most probable tokens to consider for generation top_k: 40, // optional, for nucleus sampling decoding strategy top_p: 0.95, // optional, maximum number of output tokens to generate max_output_tokens: 1024, // optional, sequences at which to stop model generation stop_sequences: stopSequences, // optional, safety settings safety_settings: [{"category":"HARM_CATEGORY_DEROGATORY","threshold":1},{"category":"HARM_CATEGORY_TOXICITY","threshold":1},{"category":"HARM_CATEGORY_VIOLENCE","threshold":2},{"category":"HARM_CATEGORY_SEXUAL","threshold":2},{"category":"HARM_CATEGORY_MEDICAL","threshold":2},{"category":"HARM_CATEGORY_DANGEROUS","threshold":2}], prompt: { text: promptString, }, }).then(result => { console.log(JSON.stringify(result, null, 2)); });


প্রথমত, দেখুন প্রমাণীকরণ কতটা সহজ - আমাকে আক্ষরিক অর্থেই আমার কী পেস্ট করতে হবে। আমি অতীতে প্রচুর Google API ব্যবহার করেছি এবং প্রায় প্রতিবারই প্রমাণীকরণটি পিছনে একটি ব্যথা। (এটি সম্ভবত সম্পূর্ণরূপে আমার দোষ!) এছাড়াও, নমুনা কোডের জন্য এখানে মন্তব্য করার দুর্দান্ত ব্যবহার নোট করুন। আমি সৎ থাকব এবং মন্তব্যের সাথেও বলব, এখানে এমন কিছু জিনিস আছে যা আমি পুরোপুরি পাই না, কিন্তু এর বাইরে, আমি স্থানীয়ভাবে প্রায় অবিলম্বে এটি চালিয়েছিলাম।


এখানে এর ফলাফল:


 [ { "candidates": [ { "safetyRatings": [ { "category": "HARM_CATEGORY_DEROGATORY", "probability": "NEGLIGIBLE" }, { "category": "HARM_CATEGORY_TOXICITY", "probability": "NEGLIGIBLE" }, { "category": "HARM_CATEGORY_VIOLENCE", "probability": "NEGLIGIBLE" }, { "category": "HARM_CATEGORY_SEXUAL", "probability": "NEGLIGIBLE" }, { "category": "HARM_CATEGORY_MEDICAL", "probability": "NEGLIGIBLE" }, { "category": "HARM_CATEGORY_DANGEROUS", "probability": "NEGLIGIBLE" } ], "output": "Once upon a time, there was a magic cat named Mr. Mistoffelees. He was a very special cat, because he could only do magic when he spoke in reverse.\n\nOne day, Mr. Mistoffelees was playing in the forest when he saw a little girl who was crying. \"What's wrong?\" he asked.\n\n\"I'm lost,\" the little girl said. \"I can't find my way home.\"\n\nMr. Mistoffelees smiled. \"Don't worry,\" he said. \"I can help you.\"\n\nHe took a deep breath and said, \"Sdrawkcab eht revo spmuj I.\"\n\nSuddenly, the little girl was surrounded by a bright light. When the light faded, she was standing in front of her house.\n\n\"Thank you!\" she said. \"You're a lifesaver!\"\n\nMr. Mistoffelees smiled. \"You're welcome,\" he said. \"Just remember, my magic only works when I speak in reverse.\"\n\nThe little girl nodded. \"I'll remember,\" she said.\n\nThe next day, the little girl was playing in the forest again when she saw a group of boys picking on a smaller boy.\n\n\"Leave him alone!\" she shouted.\n\nThe boys turned to look at her. \"What are you going to do about it?\" one of them asked.\n\nThe little girl took a deep breath and said, \"Sdrawkcab eht revo spmuj I.\"\n\nSuddenly, the boys were surrounded by a bright light. When the light faded, they were all wearing dresses.\n\nThe boys started to laugh. \"What happened to our clothes?\" they asked.\n\n\"That's what you get for picking on a smaller boy,\" the little girl said.\n\nThe boys ran away, laughing.\n\nThe little girl smiled. \"I guess my magic really does work,\" she said.\n\nMr. Mistoffelees was watching from a nearby tree. He smiled. \"I'm glad my magic could help you,\" he said.\n\nThe little girl smiled back. \"Thanks, Mr. Mistoffelees,\" she said. \"You're the best.\"\n\nMr. Mistoffelees purred. \"You're welcome,\" he said. \"I'm always happy to help.\"\n\nThe little girl and Mr. Mistoffelees continued to play in the forest together. They had many more adventures, and Mr. Mistoffelees' magic always helped them out. But even though his magic was powerful, it was also very silly. And it always seemed to backfire in a humorous way.\n\nOne day, Mr. Mistoffelees was trying to help the little girl get a bird out of a tree. He said, \"Sdrawkcab eht revo spmuj I.\"\n\nSuddenly, the bird flew out of the tree and landed on the little girl's head.\n\nThe little girl laughed. \"Thanks, Mr. Mistoffelees,\" she said. \"But I think I would have been able to get the bird out of the tree myself.\"\n\nMr. Mistoffelees purred. \"You're welcome,\" he said. \"I'm just glad I could help.\"\n\nThe little girl and Mr. Mistoffelees continued to play together. They had many more adventures, and Mr. Mistoffelees' magic always helped them out. And even though his magic was silly, it was always kind and helpful." } ], "filters": [], "safetyFeedback": [] }, null, null ]


আমি নিরাপত্তা রেটিং দিকটিকে সবচেয়ে আকর্ষণীয় বলে মনে করি, কারণ এটি আপনার স্বয়ংক্রিয় প্রতিক্রিয়াগুলিতে 'গার্ড্রেল' যোগ করার একটি দুর্দান্ত উপায় বলে মনে হচ্ছে।


আমি এটির সাথে খেলার পরে, আমি "ডেটা প্রম্পট" বৈশিষ্ট্যটি দেখেছিলাম:


ডেটা প্রম্পট UI


আমি যা বলতে পারি তা থেকে, এই বৈশিষ্ট্যটি আপনাকে ডেটার একটি নমুনা তালিকা নিতে দেয় এবং সেই ইনপুটের উপর ভিত্তি করে, আপনি তারপরে ডেটার অতিরিক্ত সারি যোগ করতে পারেন এবং PaLM-কে সংশ্লিষ্ট দ্বিতীয় কলাম নির্দিষ্ট করতে পারেন। আমি 'বিপরীত' নমুনা ব্যবহার করেছি কারণ এটি সবচেয়ে সহজ বলে মনে হয়েছিল:


বিপরীতের জন্য নমুনা সারণী ডেটা


তাদের নমুনার সাথে চলমান প্রত্যাশিতভাবে কাজ করে:


ইনপুট হিসাবে ভুল এবং দ্রুত, আপনি প্রতিক্রিয়া হিসাবে সঠিক এবং ধীর পাবেন


আমি "বোবা", "ঠান্ডা", এবং "বাম" চেষ্টা করেছি এবং পেয়েছি:


বোবা, ঠান্ডা এবং বাম দেওয়া, আমি পেয়েছি: কোন বিষয়বস্তু, গরম, এবং ডান


আপনি দেখতে পাচ্ছেন, এটি বোবার বিপরীতে খুঁজে পেতে ব্যর্থ হয়েছে তবে অন্যদের জন্য সঠিকভাবে কাজ করেছে। এর জন্য কোড, আমি যা দেখতে পাচ্ছি তা থেকে, একটি প্রম্পটে ট্যাবুলার ডেটাকে 'ফরম্যাট' করে:


 const { TextServiceClient } = require("@google-ai/generativelanguage"); const { GoogleAuth } = require("google-auth-library"); const MODEL_NAME = "models/text-bison-001"; const API_KEY = "YOUR API KEY"; const client = new TextServiceClient({ authClient: new GoogleAuth().fromAPIKey(API_KEY), }); const Word = 'Left'; const promptString = `Find a word or phrase with opposite meaning. Word: Strong Opposite: Weak Word: Thick Opposite: Thin Word: Sparse Opposite: Dense Word: Sloppy Opposite: Organized Word: ${Word} Opposite:`; const stopSequences = []; client.generateText({ // required, which model to use to generate the result model: MODEL_NAME, // optional, 0.0 always uses the highest-probability result temperature: 0.7, // optional, how many candidate results to generate candidateCount: 1, // optional, number of most probable tokens to consider for generation top_k: 40, // optional, for nucleus sampling decoding strategy top_p: 0.95, // optional, maximum number of output tokens to generate max_output_tokens: 1024, // optional, sequences at which to stop model generation stop_sequences: stopSequences, // optional, safety settings safety_settings: [{"category":"HARM_CATEGORY_DEROGATORY","threshold":1},{"category":"HARM_CATEGORY_TOXICITY","threshold":1},{"category":"HARM_CATEGORY_VIOLENCE","threshold":2},{"category":"HARM_CATEGORY_SEXUAL","threshold":2},{"category":"HARM_CATEGORY_MEDICAL","threshold":2},{"category":"HARM_CATEGORY_DANGEROUS","threshold":2}], prompt: { text: promptString, }, }).then(result => { console.log(JSON.stringify(result, null, 2)); });


উল্লেখ্য একটি জিনিস, যদিও, ভেরিয়েবলগুলি প্রম্পটে অনুমোদিত, যা বেশ দুর্দান্ত। যখন আমি এটি চালাই, আউটপুট (বিশেষত JSON-এ output মান, আমি ফলাফলের ফলাফল উপেক্ষা করছি) ছোট এবং মিষ্টি ছিল: "ঠিক," যা চমৎকার। আমার অনুমান আরো জটিল এবং আপনার টেবিল সম্পূর্ণ, ভাল এটি কাজ করবে.


তাই... প্রথম ইম্প্রেশন - আমি সত্যিই খনন করছি যে কতটা ভালোভাবে মেকারসুইট আমাকে ওয়েবে পরীক্ষা করতে দেয় এবং কত দ্রুত আমি সেটিকে কোডে নিতে এবং কাজ শুরু করতে পারি। আমি এতটাই প্রভাবিত হয়েছিলাম যে গতকাল, আমি এটির সাথে প্রায় বিশ মিনিটের মধ্যে একটি "বাস্তব" ডেমো তৈরি করেছি।


এছাড়াও এখানে প্রকাশিত.