Gemma: Google's Open-Source LLM Empowering AI

Discover Gemma, Google's open-source language model (LLM) designed for performance and accessibility. Unlock AI innovation now!

Google Gemma
Gemma: Google's Open-Source LLM Empowering AI

Gemma, Google's innovative open-source Large Language Model (LLM), unlocks new possibilities for AI exploration and development. It empowers developers and researchers to explore new frontiers in AI. Its name, Google Exploratory Models for Multitask AI, reflects its potential to charter new territories in generative text, code creation, and beyond.

Gemma comes in two sizes, Gemma 2B and Gemma 7B, offering pre-trained and instruction-tuned versions for maximum flexibility. Whether you're working on a personal laptop or leveraging powerful Google Cloud TPUs and NVIDIA GPUs, Gemma can adapt to your needs. Designed to excel in text-based tasks, it draws knowledge from a massive 6 trillion token dataset of web content, code, and mathematical problems. This diverse training makes Gemma a versatile tool, ready to generate code, tackle complex maths questions, and handle a variety of language formats.

Join us as we delve into Gemma's capabilities, testing its prowess in language understanding, mathematical reasoning, and coding challenges. Expect impressive results alongside areas where Gemma continues to learn, offering a transparent view of this powerful technology.

Key Takeaways

  • Gemma Offer Practical Benefits: Gemma's ability to draft emails, solve basic maths problems, and generate code reveals that it is ready for real-world applications. 
  • Gemma Isn't Perfect (Yet): While Gemma excels in many areas, its shortcomings in humour, complex calculations, and intricate coding illustrate that it doesn't always match human-level reasoning. 
  • Open-Source Fuels AI Progress: Gemma's open-source nature means developers and researchers worldwide can explore, improve, and customise it. This open model encourages innovation and the development of AI tools that serve diverse needs.

6 Trillion Token Dataset: Gemma's Learning Advantage

Imagine learning a new language. You start with a small book, but to become a super-speaker, you need to hear it everywhere and try all sorts of new words!  Gemma learns the same way, but instead of books, it has a gigantic digital library with 6 trillion words, code, and conversations.

Gemma breaks this giant library into smaller pieces called tokens. Think of tokens like puzzle pieces - not just whole words, but also parts of words, numbers, and even symbols. The more tokens Gemma sees, the smarter it gets. Just like you learn best by reading a lot, so does Gemma!

Gemma's Place Among Giants

  • When we compare Gemma to other big names in language models, we see that many are trained on huge amounts of tokens — from hundreds of billions to even trillions. Being part of the "trillion token club" shows Gemma has a lot of learning power behind it. Here's how it stacks up:
  • GPT-3: Learned from hundreds of billions of tokens, mixing text and code.
  • Megatron-Turing NLG: Also plays in the trillion-token league.
  • Google's larger models (like the Gemini family): These heavyweights often train with multiple trillions of tokens.

Gemma packs a surprising punch! Even its smaller 2B and 7B parameter models often outperform much larger language models. This efficiency means you can achieve cutting-edge AI results without needing supercomputer-level hardware. Open-source access is Gemma's superpower. Researchers can peek under the hood, fine-tune it for specialised tasks, and the whole community benefits from shared knowledge and innovation.

Gemma democratises AI experimentation, proving powerful tools don't have to be resource-heavy. Work with Gemma on standard laptops and desktops and even mobiles, expanding the possibilities for students, independent researchers, and smaller businesses.

Gemma works seamlessly with popular frameworks like Keras 3.0, PyTorch, JAX, and Hugging Face Transformers. This flexibility lets developers keep using the tools they love and speeds up integration into real-world projects.

Gemma in Action

Let's see how Gemma's performance shines in real-world tasks. We'll explore its abilities across three domains: language understanding, mathematical reasoning, and coding skills. To get a well-rounded view, we'll tackle both everyday tasks and tougher challenges.

Language Understanding

Language understanding is the ability of a computer to extract meaning from human language, just like a person would. A model with good language understanding should be able to understand instructions and tasks provided in natural language like English and should be able to follow them to the spirit. So for the first task I ask it to write an email:Here is the prompt:

prompt = """
Write a an email to prospective business client, telling them about the services offered by TipzAI.
TipzAI offers AI Feasibility study, AI strategy building and AI implementation services.
Additionally it also offers AI consulting services.

And Gemma’s response:

Subject: Empowering Businesses with AI: TipzAI's Comprehensive Services

Dear [Prospective Client Name],

I hope this email finds you well. My name is [Your Name] from TipzAI, a leading AI consulting firm specializing in helping businesses unlock their full potential through AI implementation.

We understand that navigating the complex world of AI can be daunting for many organizations. That's why we offer a range of services designed to guide you through each step of your AI journey.

**Our Services:**

* **AI Feasibility Study:** We meticulously assess your business needs and identify the most viable AI applications for maximum impact.
* **AI Strategy Building:** We develop a tailored strategy outlining how AI can transform your operations and drive growth.
* **AI Implementation:** We implement AI solutions with precision, ensuring seamless integration and maximum ROI.
* **AI Consulting:** We provide ongoing consulting services to help you manage and optimize your AI initiatives.

We're passionate about helping businesses unlock the power of AI. We believe that AI has the potential to revolutionize your industry, and we're committed to helping you harness its transformative power.

Would you like to schedule a free consultation to discuss your business goals and explore how TipzAI can help you achieve them?

Please feel free to reach me at [Your Email Address] or [Your Phone Number]. I'm available to answer any questions you may have.

[Your Name]

Gemma generates a grammatically correct and professional email, showcasing its understanding of instructions and business communication. Next, I ask it to interpret a classical example of syntactic ambiguity:


prompt = "Interpret the meaning of this text: Time flies like an arrow; fruit flies like a banana"

And here is the response from Gemma:

Sure, here is the interpretation of the text:

The text is a metaphorical saying that compares the passage of time to the flight of an arrow, and the swiftness of fruit flies to the flight of a banana.

**The meaning:**

- **Time flies like an arrow:** This phrase emphasizes the swiftness and irrevocability of time. Once time has flown, it cannot be recovered.
- **Fruit flies like a banana:** This phrase compares the fruit flies' quick and erratic movements to the speedy and curved trajectory of a banana. It highlights the unpredictable nature of time.

**Overall, the text is a reminder to appreciate the fleeting nature of time and to live life to the fullest.**

While the interpretation Gemma provided captures a creative and metaphorical understanding of the phrase "Time flies like an arrow; fruit flies like a banana," it slightly misses the original intent and humour behind it. The original phrasing is a humorous play on words. It deliberately uses syntactic ambiguity where 'flies' can be interpreted as both a noun and a verb. This illustrates Gemma's current limitations in fully grasping linguistic nuances and humour, an area where human insight still reigns supreme.

Maths Problem Solving

Maths problem solving is the process of applying mathematical concepts and techniques to find solutions to real-world or abstract problems. And so I start with a Quadratic equation solving problem.

Here is the prompt:

prompt = """ Rahul and Rohan have 45 marbles together. After losing 5 marbles each, the product of the number of marbles they both have now is 124. How to find out how many marbles they had to start with."""

The model response is:

**1. Calculate the number of marbles remaining after losing 5 marbles each:**

- Rahul has 45 - 5 = 40 marbles
- Rohan has 45 - 5 = 40 marbles

**2. Find the product of the number of marbles remaining:**

- Product = 40 * 40 = 1600

**3. Set the product equal to 124 and solve for the original number of marbles:**

- 1600 = 45x
- x = 1600/45
- x = 36

Therefore, Rahul and Rohan had a total of 36 marbles to start with.

Solving equations involving squared terms, Gemma demonstrates its ability to follow step-by-step problem-solving and provide accurate solutions for simple mathematical problems.  Now let us make it slightly more complicated. Here is my prompt:

prompt = """Solve the following problem, give step by step answer for each part: Alice, Bob, and Charlie decide to invest in a new tech startup. Alice invests twice as much as Bob, while Charlie invests $5,000 more than Bob. Together, their total investment in the startup is $85,000.

Part A: Determine how much each person invested.

Part B: After a year, the startup sees a significant return on investment (ROI). The total amount received from the investment is $127,500. Assuming the profit is distributed in direct proportion to their initial investments, calculate how much profit each person made."""

And Gemma’s response:

**Part A:**

1. **Calculate Alice's investment:**
   - Alice invests twice as much as Bob. Let's assume Bob invests $x. Therefore, Alice invests $2x.

2. **Calculate Charlie's investment:**
   - Charlie invests $5,000 more than Bob. So, Charlie invests $x + 5,000.

3. **Set the total investment equal to the sum of investments:**
   - $x + 2x + (x + 5,000) = 85,000

4. **Solve for x:**
   - $x + 2x + x + 5,000 = 85,000
   - 3x + 5,000 = 85,000
   - 3x = 80,000 - 5,000 = 75,000
   - x = 25,000

**Part B:**

1. **Calculate the profit share for each person:**
   - The profit is distributed in direct proportion to initial investments. So, Bob's share of profit is $x/85,000 * 127,500.
   - Alice's share of profit is $2x/85,000 * 127,500.
   - Charlie's share of profit is $(x + 5,000)/85,000 * 127,500.

2. **Calculate the total profit received:**
   - Bob's profit = $x/85,000 * 127,500 = $25,000
   - Alice's profit = $2x/85,000 * 127,500 = $50,000
   - Charlie's profit = $(x + 5,000)/85,000 * 127,500 = $52,500

Therefore, the total investment for each person is:

* **Bob:** $25,000
* **Alice:** $50,000
* **Charlie:** $52,500

And the profit earned by each person is:

* **Bob:** $25,000
* **Alice:** $50,000
* **Charlie:** $52,500

Wow! it looks great- but on deeper analysis- we find that while it correctly understood the problem, it was not able to solve the equations correctly. Gemma correctly understood the problem and its multi-step nature. However, it made a calculation error demonstrating the ongoing challenge of perfect numerical accuracy in LLMs.

Coding Challenges

Coding challenges are tasks that test a programmer's ability to design algorithms, write code, and solve computational problems. Here Gemma is our programmer, to test, I start with an advanced problem in Data structures, here is the prompt:

prompt = """
Write a program in Python that:
Given an array arr[] of size N, the task is to count the number of array elements whose sum of digits is equal to K.


Input: arr[] = {23, 54, 87, 29, 92, 62}, K = 11
Output: 2
29 = 2 + 9 = 11
92 = 9 + 2 = 11

Input: arr[]= {11, 04, 57, 99, 98, 32}, K = 18
Output: 1

And the result:

def sumDigit(n):
    sum = 0
    while n:
        digit = n % 10
        sum += digit
        n //= 10
    return sum

def findNumberOfSumK(arr, K):
    count = 0
    for num in arr:
        if sumDigit(num) == K:
            count += 1
    return count

arr = [23, 54, 87, 29, 92, 62]
K = 11
print(findNumberOfSumK(arr, K))  # Output: 2

arr = [11, 04, 57, 99, 98, 32]
K = 18
print(findNumberOfSumK(arr, K))  # Output: 1


- The `sumDigit` function calculates the sum of digits in a given number.
- The `findNumberOfSumK` function iterates over the `arr` array and checks if the sum of digits for each element is equal to `K`. If it is, it increments the `count` variable.
- The function returns the `count` variable as the final result.

**Time complexity:**

- The `sumDigit` function takes O(1) time complexity as it performs a constant number of operations regardless of the input number.
- The `findNumberOfSumK` function iterates over the `arr` array only once, so its time complexity is O(N) where N is the size of the array.

**Space complexity:**

- The `sumDigit` function uses a constant amount of space regardless of the input size.
- The `findNumberOfSumK` function uses a constant amount of space as well, as it does not use any additional data structures.

Creating and manipulating basic data collections, Gemma excels by providing correct code with clear explanations. This demonstrates its grasp of algorithms and programming concepts.  Next, we'll challenge Gemma with a classic dynamic programming problem:

prompt = """write a python code for the given Problem Statement:

Given an array of integers, find the maximum sum of elements you can obtain by adding up numbers such that no two elements are adjacent in the original array.

The number of elements in the array,n, satisfies 1≤n≤10^4.
Each element,arr[i], satisfies −10^4 ≤arr[i]≤10^4.
Input Format:
An array of integers.
Output Format:
An integer representing the maximum sum of non-adjacent elements.

Here is its response for this complex coding challenge:

def findMaxSum(arr):
    n = len(arr)
    dp = [0] * n

    # Calculate the maximum sum for the first element
    dp[0] = arr[0]

    # Calculate the maximum sum for the second element
    dp[1] = max(arr[0] + arr[1], arr[1])

    # Iterate over the remaining elements and update the maximum sum
    for i in range(2, n):
        dp[i] = max(dp[i-1] + arr[i], dp[i-2] + arr[i])

    # Return the maximum sum
    return dp[n-1]


* The code calculates the maximum sum of non-adjacent elements in an array using dynamic programming.
* It uses an array `dp` of size `n` to store the maximum sum at each position.
* The initial value of `dp[0]` is the first element in the array.
* The initial value of `dp[1]` is the maximum of the first two elements in the array.
* For each subsequent element, `dp[i]` is updated to the maximum of `dp[i-1] + arr[i]` and `dp[i-2] + arr[i]`, where `arr[i]` is the element at the current position and `dp[i-1]` and `dp[i-2]` are the maximum sums at the previous two positions.
* Finally, the maximum sum is returned as `dp[n-1]`, which represents the maximum sum of non-adjacent elements in the array.

**Time Complexity:**

* The code iterates over the array only once, so the time complexity is O(n).

**Space Complexity:**

* The code uses an array `dp` of size `n`, so the space complexity is O(n).

Gemma grasps the essence of the task – to write a function for finding the maximum non-adjacent sum. It recognizes the potential of dynamic programming. It also demonstrates good coding fundamentals in setting up a dp array and attempting to track maximums through iteration. However its logic for dp[1] and the loop formula highlights a misinterpretation of the non-adjacency rule. Additionally, the code lacks checks for common dynamic programming edge cases.

Unleashing Gemma's Potential

Ready to try Gemma for yourself? Here's how to access its power:

But access is just the beginning. Gemma truly shines in its adaptability and versatility. Right out of the box, it's a remarkable text generation engine. Need a whimsical poem, a working code snippet, an engaging script, or a catchy email? Gemma can help you jumpstart your creativity. It even handles translation tasks, bridging the gap between languages for business or personal communication.

Not only this, by fine-tuning Gemma, you can tailor it to your specific needs. Teach it to condense lengthy articles into concise summaries, or build a question-answering system that draws from your proprietary knowledge base.

What's more, Gemma's compact size opens up exciting possibilities.  You can potentially integrate it within apps, embed it on mobile devices, or harness its power with cloud-based solutions.

While incredibly powerful, it's important to remember that LLMs like Gemma still have limitations, including occasional errors in calculation or misunderstandings of complex instructions.  Yet, these challenges pave the way for exciting advancements and make Gemma an invaluable asset for AI exploration.


In this blog post we explored Gemma's remarkable capabilities and highlighted areas where large language models continue to evolve. Gemma excels in tasks requiring clarity and grammatical accuracy, like email drafting. It demonstrated an understanding of mathematical concepts and problem-solving steps. Additionally, Gemma's grasp of coding fundamentals and algorithms was evident in its successful data structures challenge. However, subtle language interpretation tasks like humour, complex mathematical calculations, and intricate coding paradigms like dynamic programming revealed areas for further refinement. Overall, Gemma showcases the impressive potential of open-source LLMs while underscoring the ongoing journey towards AI models that perfectly mirror human-level reasoning and problem-solving.

This performance snapshot of Gemma reveals a powerful yet evolving tool, capable of impressive feats with certain limitations that remind us of the journey AI still has to undertake towards achieving nuanced understanding and problem-solving akin to human intelligence, especially with limited resources and compute power.


Amita Kapoor: Author, Research & Code Development
Narotam Singh: Copy Editor, Design & Digital Management

Consent Preferences