Google hat mit seinen Gemini 2.0 -Modellen Wellen im KI -Raum geschafft und wesentliche Upgrades auf ihre Chatbot- und Entwickler -Instruments gebracht. Mit der Einführung von Gemini 2.0 Flash, Gemini 2.0 Professional (experimentell) und dem neuen kosteneffizienten Gemini 2.0 Flash-Lite battle ich bestrebt, mit jedem dieser Modelle praktische Erfahrungen zu sammeln-und ja, ich habe sie alle für versucht frei!
Wie bekomme ich Gemini 2.0 API?
Schritt 1: Geh dazu Hyperlink.
![](https://cdn.analyticsvidhya.com/wp-content/uploads/2025/02/How-to-Get-Gemini-2.0-API_.webp)
Schritt 2: Klicken Sie auf „Holen Sie sich eine Gemini -API -Style“
Schritt 3: Klicken Sie nun auf „API -Schlüssel erstellen“
![](https://cdn.analyticsvidhya.com/wp-content/uploads/2025/02/Create-API-Key.webp)
Schritt 4: Wählen Sie ein Projekt aus Ihren vorhandenen Google Cloud -Projekten aus.
![](https://cdn.analyticsvidhya.com/wp-content/uploads/2025/02/Select-a-project-from-your-existing-Google-Cloud-projects.webp)
Schritt 5: Suche Google Cloud -Projekte. Dies generiert den API -Schlüssel für Ihr Projekt!
![](https://cdn.analyticsvidhya.com/wp-content/uploads/2025/02/Search-Google-Cloud-Projects.webp)
Praktisch mit Gemini 2.0 Flash
![](https://cdn.analyticsvidhya.com/wp-content/uploads/2025/02/Gemini-2.0-Flash.webp)
Gemini 2.0 Flash, zunächst eine experimentelle Veröffentlichung, ist jetzt weithin zugänglich und in verschiedene Google AI -Produkte integriert. Nachdem ich es durch die Gemini -API in Google AI Studio und Vertex AI getestet hatte, fand ich es eine schnellere und optimiertere Model seines Vorgängers. Während es die tiefen Argumentationsfähigkeiten des Professional -Modells fehlt, behandelt es schnelle Reaktionen und allgemeine Aufgaben bemerkenswert intestine.
Um mehr über diesen Weblog zu erfahren.
Schlüsselmerkmale, die mir aufgefallen sind
- Verbesserte Geschwindigkeit: Das Modell ist sehr reaktionsschnell und macht es ideally suited für Echtzeitanwendungen.
- Bevorstehende Funktionen: Google hat für dieses Modell Textual content-to-Speech- und Bildgenerierungsfunktionen angekündigt, was es noch vielseitiger machen könnte.
- Nahtlose Integration: Zugriff über die Gemini -App, Google AI Studio und die Vertex AI, die es in verschiedenen Anwendungen leicht implementieren kann.
Code:
!pip set up -q -U google-generativeai
import google.generativeai as genai
from IPython.show import Markdown
from google.colab import userdata
GOOGLE_API_KEY=userdata.get('GOOGLE_API_KEY')
genai.configure(api_key=GOOGLE_API_KEY)
import httpx
import base64
# Retrieve a picture
image_path = "https://cdn.pixabay.com/picture/2022/04/10/09/02/cats-7122943_1280.png"
picture = httpx.get(image_path)
# Select a Gemini mannequin
mannequin = genai.GenerativeModel(model_name="fashions/gemini-2.0-flash")
# Create a immediate
immediate = "Caption this picture."
response = mannequin.generate_content(
(
{
"mime_type": "picture/jpeg",
"information": base64.b64encode(picture.content material).decode("utf-8"),
},
immediate,
)
)
Markdown(">" + response.textual content)
Ausgabe:
![](https://cdn.analyticsvidhya.com/wp-content/uploads/2025/02/Gemini-2.0-Flash-Output.webp)
Zwei Cartoon -Katzen interagieren mit einer großen Blume. Die Katze hyperlinks ist braun mit braunen Streifen und greift nach einem großen grünen Blatt. Die Katze rechts ist grau mit dunkleren grauen Streifen und schaut mit Interesse zur Blume auf. Die Blume hat orange Blütenblätter und ein blasses Zentrum. Es gibt auch einige glatte Steine an der Foundation der Blume. Der Hintergrund ist eine hellblaue Farbe.
Lesen Sie auch: Gemini 2.0 Flash gegen GPT 4O: Was ist besser?
Testing Gemini 2.0 Professional (experimentell)
![](https://cdn.analyticsvidhya.com/wp-content/uploads/2025/02/Testing-Gemini-2.0-Pro-Experimental.webp)
Dieses Flaggschiff -Modell befindet sich noch in einer experimentellen Part, aber ich habe einen frühen Zugriff über Google AI Studio. Gemini 2.0 Professional ist für komplexe Argumentations- und Codierungsaufgaben konzipiert und hat den Erwartungen sicherlich erfüllt.
Meine Imbissbuden
- Massives 2m Token -Kontextfenster: Die Fähigkeit, große Datensätze effizient zu verarbeiten, ist ein Sport-Changer.
- Fortgeschrittene Argumentation: Verarbeitet mehrstufige Problemlösungen besser als jedes frühere Gemini-Modell.
- Beste Codierungsleistung: Ich habe es mit Programmierherausforderungen getestet und es übertraf andere Gemini -Modelle bei der Generierung strukturierter und optimierter Code.
- Werkzeugintegration: Das Modell kann die Google -Such- und Codeausführung nutzen, um die Antworten zu verbessern.
Gemini 2.0 Professional ist ab sofort als experimentelles Modell für Entwickler in Google AI Studio und Vertex AI sowie für Gemini Superior-Benutzer in der Dropdown-Dropd-Down-Marke auf Desktop und Cellular verfügbar.
Um mehr über diesen Weblog zu erfahren.
Code:
pip set up -q -U google-genai
from google import genai
# Exchange "YOUR_API_KEY" along with your precise API key
shopper = genai.Consumer(api_key="Your_API_Key")
response = shopper.fashions.generate_content(
mannequin="gemini-2.0-pro-exp-02-05", contents="Give me code for nth fabonacci collection"
)
print(response.textual content)
Ausgabe:
def fibonacci_nth(n):
"""
Calculates the nth Fibonacci quantity.
Args:
n: The index of the specified Fibonacci quantity (non-negative integer).
Returns:
The nth Fibonacci quantity. Returns 0 if n is 0. Returns 1 if n is 1.
Handles invalid enter (damaging numbers) by elevating a ValueError.
Raises:
ValueError: if n is damaging.
"""
if n < 0:
increase ValueError("Enter have to be a non-negative integer.")
elif n <= 1:
return n # Base circumstances: F(0) = 0, F(1) = 1
else:
a, b = 0, 1
for _ in vary(2, n + 1):
a, b = b, a + b # Effectively replace a and b
return bdef fibonacci_series(n):
"""
Generates the primary n Fibonacci numbers.
Args:
n: The variety of Fibonacci numbers to generate (non-negative integer).
Returns:
An inventory containing the primary n Fibonacci numbers. Returns an empty checklist if n is 0.
Handles invalid enter (damaging n) by elevating a ValueError.
Raises:
ValueError: if n is damaging.
"""
if n < 0:
increase ValueError("Enter have to be a non-negative integer.")
elif n == 0:
return ()
elif n == 1:
return (0)
else:
collection = (0, 1)
whereas len(collection) < n:
next_fib = collection(-1) + collection(-2)
collection.append(next_fib)
return collectiondef fibonacci_recursive(n):
"""
Calculates the nth Fibonacci quantity utilizing recursion.
Args:
n: The index of the specified Fibonacci quantity (non-negative integer).
Returns:
The nth Fibonacci quantity.
Raises:
ValueError: if n is damaging.
"""
if n < 0:
increase ValueError("Enter have to be a non-negative integer.")
elif n <= 1:
return n
else:
return fibonacci_recursive(n - 1) + fibonacci_recursive(n - 2)def fibonacci_memoization(n, memo={}):
"""
Calculates the nth Fibonacci quantity utilizing recursion with memoization.
Args:
n: The index of the specified Fibonacci quantity (non-negative integer)
memo: A dictionary to retailer beforehand computed Fibonacci numbers.
Returns:
The nth Fibonacci quantity.
Raises:
ValueError: if n is damaging.
"""
if n < 0:
increase ValueError("Enter have to be a non-negative integer.")
if n in memo:
return memo(n)
if n <= 1:
return n
memo(n) = fibonacci_memoization(n - 1, memo) + fibonacci_memoization(n - 2, memo)
return memo(n)def fibonacci_golden_ratio(n):
"""
Calculates the nth Fibonacci quantity utilizing the Golden Ratio system (Binet's system).
Args:
n: The index of the specified Fibonacci quantity (non-negative integer).
Returns:
The nth Fibonacci quantity, rounded to the closest integer. As a result of floating-point
precision, this technique is perhaps inaccurate for very massive values of n.
Raises:
ValueError: if n is damaging.
"""
if n < 0:
increase ValueError("Enter have to be a non-negative integer.")
phi = (1 + 5**0.5) / 2 # Golden Ratio
return spherical((phi**n - (1 - phi)**n) / (5**0.5))# --- Examples and Testing ---
if __name__ == "__main__":
# Check circumstances
test_cases = (0, 1, 2, 3, 4, 5, 6, 7, 10, 20, 30)
print("Iterative Technique:")
for n in test_cases:
print(f"F({n}) = {fibonacci_nth(n)}")
print("nSeries Technique:")
for n in test_cases:
print(f"First {n} Fibonacci numbers: {fibonacci_series(n)}")
print("nRecursive Technique (Warning: Gradual for bigger n):")
for n in test_cases(:10): # Restrict recursive exams for efficiency
print(f"F({n}) = {fibonacci_recursive(n)}")
print("nMemoization Technique:")
for n in test_cases:
print(f"F({n}) = {fibonacci_memoization(n)}")
print("nGolden Ratio Technique:")
for n in test_cases:
print(f"F({n}) = {fibonacci_golden_ratio(n)}")
# Instance of dealing with invalid enter
strive:
print(fibonacci_nth(-1))
besides ValueError as e:
print(f"Error: {e}")
strive:
print(fibonacci_series(-5))
besides ValueError as e:
print(f"Error: {e}")
strive:
fibonacci_recursive(-2)
besides ValueError as e:
print(f"Error: {e}")
strive:
fibonacci_memoization(-3)
besides ValueError as e:
print(f"Error: {e}")
strive:
fibonacci_golden_ratio(-4)
besides ValueError as e:
print(f"Error: {e}")
# Bigger worth testing (iterative and memoization are a lot quicker)
large_n = 40
print(f"nF({large_n}) (Iterative) = {fibonacci_nth(large_n)}")
print(f"F({large_n}) (Memoization) = {fibonacci_memoization(large_n)}")
# print(f"F({large_n}) (Recursive) = {fibonacci_recursive(large_n)}") # Very gradual! Keep away from for giant n.
print(f"F({large_n}) (Golden Ratio) = {fibonacci_golden_ratio(large_n)}")
Erkundung von Gemini 2.0 Flash-Lite: Das kostengünstigste Modell
![](https://cdn.analyticsvidhya.com/wp-content/uploads/2025/02/Exploring-Gemini-2.0-Flash-Lite_-The-Most-Cost-Efficient-Model.webp)
Gemini 2.0 Flash-Lite ist das budgetfreundliche KI-Modell von Google und bietet ein Gleichgewicht zwischen Leistung und Erschwinglichkeit. Im Gegensatz zu seinen Vorgängern bietet es a 1m Token Kontextfenster Und Multimodaleingangsunterstützung Beibehaltung der Geschwindigkeit des vorherigen 1,5 -Flash -Modells.
Was ist für mich aufgefallen?
- Ideally suited für kosten smart Anwendungen: Dieses Modell ist eine gute Wahl für Unternehmen oder Entwickler, die die KI -Ausgaben senken möchten.
- Glätte Leistung: Obwohl es nicht so mächtig wie Profi ist, ist es für allgemeine Aufgaben intestine.
- Öffentliche Vorschau verfügbar: Keine Einschränkungen – Jedes kann es über Google AI Studio und Vertex AI versuchen.
Um mehr über diesen Weblog zu erfahren.
Code:
pip set up -q -U google-genai
from google import genai
# Exchange "YOUR_API_KEY" along with your precise API key
shopper = genai.Consumer(api_key="Your_API_Key")
# Generate content material with streaming
response_stream = shopper.fashions.generate_content_stream(
mannequin="gemini-2.0-flash-lite-preview-02-05",
contents="Give me a bedtime story for my child"
)
# Course of and print the streamed response
for chunk in response_stream:
print(chunk.textual content, finish="", flush=True) # Print every chunk because it arrives
Ausgabe:
Okay, snuggle in tight and shut your eyes. Let's start...As soon as upon a time, in a land full of marshmallow clouds and lollipop bushes, lived just a little firefly named Flicker. Flicker wasn't simply any firefly, oh no! He had the brightest, sparkliest gentle in the entire valley. However generally, Flicker was just a little bit shy, particularly when it got here to shining his gentle at nighttime.
Because the solar started to dip behind the giggle-berry bushes, portray the sky in shades of orange and purple, Flicker would begin to fear. "Oh pricey," he'd whisper to himself, "It is getting darkish! I hope I haven't got to shine tonight."
All the opposite fireflies beloved to twinkle and dance within the night time sky, their lights making a magical, shimmering ballet. They’d zoom and swirl, leaving trails of glowing mud, whereas Flicker hid behind a giant, cozy dandelion.
One night time, as Flicker was hiding, he noticed just a little misplaced bunny, no larger than his thumb, hopping round in circles. The bunny was sniffing the air and whimpering softly. “Oh pricey, I am misplaced!” the bunny squeaked. “And it is so darkish!”
Flicker’s tiny coronary heart thumped in his chest. He actually wished to remain hidden, however he could not bear to see the little bunny scared and alone. Taking a deep breath, Flicker took a leap of religion.
He flew out from behind the dandelion, and with just a little *flick!*, his gentle shone brightly! It wasn't a giant, booming gentle, not at first. However it was sufficient!
The little bunny perked up his ears and noticed the glowing firefly. “Ooooh! You are shining!” the bunny cried. “Are you able to assist me?”
Flicker, stunned by his personal braveness, fluttered nearer and, with a mild *flicker* and *flicker*, started to steer the bunny alongside a path fabricated from glowing mushrooms. His gentle guided the bunny previous sleepy snails and babbling brooks till, lastly, they reached the bunny's cozy burrow, nestled below the roots of an enormous, whispering willow tree.
The bunny turned and checked out Flicker, his eyes shining with gratitude. "Thanks!" he squeaked. "You saved me! You had been so courageous and your gentle is so stunning."
As Flicker flew again in direction of the giggle-berry bushes, he felt a heat feeling unfold by means of his little firefly physique. It wasn't simply the heat of the night time; it was the heat of serving to another person.
That night time, and each night time after, Flicker flew with the opposite fireflies. He nonetheless felt just a little shy generally, however he all the time remembered the little misplaced bunny. And due to the bunny, Flicker's gentle grew brighter and stronger with each *flick!*. He discovered that one of the simplest ways to shine is to share your gentle, and that even the littlest gentle could make a giant distinction at nighttime.
Now shut your eyes tight, toddler. Dream of marshmallow clouds and glowing fireflies. Candy goals. Goodnight.
Gemini 2.0 Flash -Denkmodus: Ein Schritt in Richtung besserer KI -Argumentation
![](https://cdn.analyticsvidhya.com/wp-content/uploads/2025/02/Gemini-2.0-Flash-Thinking-Mode_-A-Step-Towards-Better-AI-Reasoning.webp)
Dieser neue Modus verbessert, wie Gemini die Problemlösung umgeht, indem der Denkprozess explizit angezeigt wird. In der Gemini -App erhältlich, unterteilt es Probleme in kleinere Komponenten und präsentiert einen strukturierten Argumentationsansatz.
Meine Erfahrung mit dem Denkmodus
- Klare Erklärungen: Die KI bietet Schritt-für-Schritt-Aufschlüsse und erleichtert das Verständnis komplexer Antworten.
- Eher menschlicher Problemlösung: Im Gegensatz zu herkömmlichen Modellen, die sofort Antworten liefern, zeigt dieser Modus den Argumentationsprozess hinter Schlussfolgerungen.
- Zuvor beschränkt auf Entwickler: Jetzt in der Gemini -App erhältlich, wodurch sie für allgemeine Benutzer zugänglicher wird.
Um mehr über diesen Weblog zu erfahren.
Code:
%pip set up -U -q "google-genai"
from google.colab import userdata
GOOGLE_API_KEY=userdata.get('GOOGLE_API_KEY')
from google import genai
from google.genai import varieties
shopper = genai.Consumer(
api_key=GOOGLE_API_KEY,
# Use `v1alpha` so you possibly can see the `thought` flag.
http_options={'api_version':'v1alpha'},
)
from pprint import pprint
pprint(
shopper.fashions.get(mannequin="gemini-2.0-flash-thinking-exp-01-21")
.model_dump(exclude_defaults=True)
)
Ausgabe:
![](https://cdn.analyticsvidhya.com/wp-content/uploads/2025/02/output-1.webp)
response = shopper.fashions.generate_content(
mannequin="gemini-2.0-flash-thinking-exp-01-21",
contents="What's SFT? Clarify your reasoning step-by-step."
print(response.textual content) # Output of the LLM
print("-----")
for line in response.textual content.break up('n'):
if line.startswith("Reasoning:"): # Instance, adapt as wanted
print(line)
Ausgabe:
![](https://cdn.analyticsvidhya.com/wp-content/uploads/2025/02/unnamed-17.webp)
for half in response.candidates(0).content material.components:
show(Markdown(half.textual content))
Ausgabe:
Let's break down what SFT, or Supervised Positive-Tuning, is step-by-step.1. Understanding the Phrases:
To grasp SFT, let's dissect the identify:
Supervised: Refers to studying from labeled information, much like having a trainer present the right solutions. In supervised studying, enter information is paired with desired output information (labels).
Positive-Tuning: Implies enhancements to an current mannequin (pre-trained) by adjusting its parameters (weights) to enhance efficiency on a particular process.2. Context: Pre-trained Fashions (Basis Fashions)
SFT is usually utilized to massive pre-trained fashions in fields like Pure Language Processing (NLP) and Pc Imaginative and prescient. These fashions, skilled on huge datasets, be taught normal information patterns.
Pre-training Part: Think about a language mannequin skilled on the web's textual content, studying language nuances, vocabulary, grammar, and relationships between phrases. This part is essential for offering a stable foundational information.3. Introducing Supervised Positive-Tuning (SFT) - The Core Idea:
Submit pre-training, a mannequin typically understands textual content or pictures however might not excel in particular duties. SFT addresses this by adapting the mannequin to carry out specific duties successfully.
Aim of SFT: Adapt a pre-trained mannequin to a particular process utilizing a related, task-specific, labeled dataset.Examples of SFT:
Sentiment Evaluation:
Pre-trained mannequin: Educated on web textual content.
Activity: Decide sentiment (constructive or damaging) in film critiques.
SFT Dataset: Film critiques labeled as "constructive" or "damaging".
SFT Course of: Additional practice the mannequin on the film assessment dataset.Query Answering:
Pre-trained mannequin: Basic massive language mannequin.
Activity: Reply questions primarily based on textual content passages.
SFT Dataset: Dataset of (context passage, query, reply) triples.
SFT Course of: Practice the mannequin on this dataset.Instruction Following (for chatbots):
Pre-trained mannequin: Basic massive language mannequin.
Activity: Generate responses primarily based on consumer directions.
SFT Dataset: Directions paired with desired responses.
SFT Course of: Practice the mannequin to comply with directions and generate acceptable responses.4. How SFT Works Technically:
Initialization: Begin with the weights from the pre-trained mannequin.
Activity-Particular Coaching: Feed the mannequin with SFT dataset.
Loss Perform: Outline a operate to measure prediction accuracy in opposition to precise labels.
Optimization: Modify weights utilizing algorithms like gradient descent to attenuate loss.
Smaller Studying Fee: Use a decreased studying price to fine-tune the mannequin subtly.5. Advantages of SFT:
Improved Particular Activity Efficiency: Enhances mannequin accuracy on fine-tuned duties.
Quicker Coaching: Leverages current information, requiring much less information and time than coaching from scratch.
Activity Specialization: Tailors general-purpose fashions to excel in particular areas.
Alignment with Desired Conduct: Ensures fashions act in accordance with consumer expectations.6. SFT vs. Different Positive-Tuning Strategies:
In comparison with different strategies like Reinforcement Studying from Human Suggestions (RLHF), SFT is commonly easier and fewer computationally intensive, making it an preliminary step earlier than making use of extra advanced strategies like RLHF.7. Abstract - Step-by-Step Reasoning:
Begin with a broadly educated pre-trained mannequin.
Establish the necessity for specialization in particular duties.
Make the most of task-specific labeled information to information the mannequin's studying.
Positive-tune the mannequin's current weights to adapt it to new duties.
Optimize efficiency by means of focused changes and loss minimization.
Obtain enhanced task-specific efficiency, leveraging foundational information.In essence, SFT transforms a broadly succesful "scholar" right into a specialised professional in a focused discipline by means of targeted and supervised studying.
Welches Modell ist richtig für Sie?
Jedes dieser Gemini 2.0 -Modelle richtet sich an verschiedene Anwendungsfälle. Hier ist ein kurzer Vergleich, der auf meinen praktischen Exams basiert:
Modell | Am besten für | Kontextfenster | Verfügbarkeit |
Gemini 2.0 Blitz | Hochvolumme und Hochfrequenzaufgaben im Maßstab | 1m Token | Öffentlich |
Gemini 2.0 Professional (Exp.) | Komplexe Aufgaben, Codierung und tiefe Argumentation | 2m Token | Google AI Studio, Vertex AI |
Gemini 2.0 Flash-Lite | Kostensensitive Anwendungen, Effizienz | 1m Token | Öffentliche Vorschau |
Nachdem Sie die neuesten getestet haben Gemini 2.0 Modelle ist klar, dass Google erhebliche Fortschritte bei der KI -Entwicklung macht. Jedes Modell dient einem einzigartigen Zweck, einem Ausgleich Geschwindigkeits-, Kosten- und Argumentationsfähigkeiten Um sich auf verschiedene Benutzerbedürfnisse zu kümmern.
- Für Echtzeit hohe FrequenzaufgabenAnwesend Gemini 2.0 Blitz ist eine solide Wahl, die beeindruckende Geschwindigkeit und nahtlose Integration bietet.
- Für komplexe Problemlösungen, Kodierung und tiefe ArgumentationAnwesend Gemini 2.0 Professional (experimentell) fällt mit seinem auf 2m Token Kontextfenster und erweiterte Werkzeugintegration.
- Für kostenbewusste BenutzerAnwesend Gemini 2.0 Flash-Lite Bietet an Erschwinglich und doch mächtig Different, ohne die Leistung zu stark zu beeinträchtigen.
- Für eine bessere Erklärung in der KIDie Denkmodus führt einen strukturierten Argumentationsansatz ein und macht KI -Ausgänge transparenter und verständlicher.
Lesen Sie auch: Google Gemini 2.0 Professional Experimental besser als OpenAI O3-Mini?
Abschluss
Das Engagement von Google für Innovationen in der KI zeigt sich mit diesen Modellen und bietet Entwicklern und Unternehmen mehr Optionen, um modernste Technologie zu nutzen. Egal, ob Sie ein Forscher, ein KI-Fanatic oder ein Entwickler sind, der freie Zugang zu diesen Modellen bietet eine fantastische Gelegenheit, hochmoderne KI-Lösungen in Ihren Workflow zu erkunden und zu integrieren.
Mit fortgesetzten Verbesserungen und bevorstehenden Merkmalen wie Textual content-to-Speech- und Bildgenerierung entwickelt sich Gemini 2.0 als Hauptakteur in der sich entwickelnden KI-Landschaft. Wenn Sie überlegen, welches Modell dies verwendet werden soll, kommt es auf Ihre spezifischen Anforderungen an: Geschwindigkeit, Intelligenz oder Kosteneffizienz-und Google hat für jeden eine überzeugende Choice bereitgestellt.