Google’s Gemini API
Brochure
Incidencia de la inteligencia artificial en la composición musical
○
Sebastian Gomez
he/him
GDE in Web Technologies
10 years ago …
¿Qué es IA generativa?
¿Qué es un LLM?
[...]
[...]
[...]
[...]
0.02
0.03
0.9
0.01
0.0
…
Dogs
Rain
Drops
Fish
Wind
…
and
cats
raining
It’s
Las rosas son rojas,
Violets are blue,
Sugar is sweet,
Las rosas son rojas,
Las violetas son azules,
El azucar es dulce,
for(var i = 0
for(var i = 0; i < 10; i++) {
Los LLMs modernos�son enormes
Entity extraction
Classification
Summarization
Classic Natural Language Problems
Sentiment Analysis
Translation
…
Los LLMs nos permiten crear prototipos rápidamente
Explain this joke: “Solía ser adicto al jabón, pero ahora estoy limpio.”
El chiste es un juego de palabras con la palabra "limpio". Tiene dos significados:
User
Model
El chiste es divertido porque es inesperado. El oyente espera que el hablante esté hablando sobre el primer significado de "limpio", pero en realidad está hablando sobre el segundo significado. Esto crea una sorpresa y provoca una risa.
Dame cinco buenas ideas para proyectos de feria de ciencias.
User
Model
Search
Conversation
Content generation
Los LLMs se caracterizan por habilidades emergentes, o la capacidad de realizar tareas que no estaban presentes en modelos más pequeños.
La comprensión contextual del lenguaje humano por parte de los LLMs cambia la forma en que interactuamos con los datos y los sistemas inteligentes.
Los LLMs pueden encontrar patrones y conexiones en grandes y dispares corpus de datos.
¿Por qué los LLMs son tan diferentes?
Google el pionero de la industria del AI
Responsible AI
3,000
Researchers
7,000
Publications
Built & Tested for Safety
Privacy in design
Upholds high scientific standards
Accountable to People
Socially Beneficial
Avoid creating unfair bias
2015
Google DeepMind AlphaGo defeats Go champion
2016
Google’s DeepMind helps detect eye disease
2017
Google invents Transformer kickstarting LLM revolution
2018
Google’s groundbreaking large language model, BERT
2019
Text-to-Text
Transfer Transformer
LLM 10B P Model Open Sourced
2020
Google LaMDA
Model Trained to converse
2022
AlphaFold predicts structures of all known proteins
2023
A conversational AI Service powered by PaLM2
2024
Family of multimodal LLMs & products
Multimodalidad
Transformer
Image
Decoder
Text
Decoder
(Android AICore)
ai.google.dev/gemma
For Developers
For Consumers
For Business and Enterprise
Models
Gemini API �(in Google AI Studio + ai.google.dev)
Gemini for Google Workspace
Gemini for Google Cloud
Gemini in Vertex AI
Gemini | app and web
Gemini in the Google App
Gemini in Gmails, Docs…
Sobre lo que es esta presentación
El ecosistema de Gemini
La más avanzada inteligencia artificial de Google
Empezando con Gemini API
Entendiendo los token
import google.generativeai as genai
model = genai.GenerativeModel('models/gemini-1.5-flash')
resp = model.generate_content(
'Write the first paragraph of a story about a magic backpack')
>>> print(resp.text)
In a bustling city, amidst the vibrant tapestry of human existence, there existed a peculiar entity named Archie. Archie, however, was no ordinary backpack…
�>>> resp.usage_metadata
prompt_token_count: 11
candidate_token_count: 123
REST API + Client libraries for:
Python, Node, Swift, Java, Go, Flutter and Dart
Vertex AI
Enterprise grade support.
Full MLOps (Examples: Model evaluation, monitoring, registry)
Vertex AI
Check it out when you're
ready for production
Gemini API and Vertex AI
Both give access Gemini family of models.
Vertex AI
Patrones de uso
Gemini 1.5 Flash
Prompting
Básico
Escribe un poema sobre una mochila mágica
In a world of wonder, behold,
A backpack with tales yet untold.
Its fabric shimmers, alive with might,
A portal to realms, day and night.
Escribe un poema sobre una mochila mágica
Una mochila mágica, de piel y hebilla de plata,
guarda en su interior secretos que nunca se revelarán.
Un universo infinito en su espacio diminuto,
donde las estrellas brillan y los sueños se perpetúan.
...
Genere un breve tip sobre JavaScript. Los buenos tips son breves y contienen un ejemplo de código que muestra el consejo.
**Tip: Use Array.prototype.flat() to flatten an array of arrays.**
```javascript
const array = [[1, 2], [3, 4], [5, 6]];
console.log(array.flat());
// Output: [1, 2, 3, 4, 5, 6]
```
## Consejo rápido: Usa el operador de cortocircuito `&&` para condiciones condicionales.
Puedes simplificar tu código utilizando el operador `&&` para ejecutar una acción solo si una condición es verdadera.
```javascript
// Sin operador de cortocircuito
let message = "";
if (user) {
message = `Hola ${user.name}!`;
}
// Con operador de cortocircuito
let message = user && `Hola ${user.name}!`;
```
Este consejo es útil para evitar código repetitivo y mantener tu código limpio y conciso. ¡Intenta usarlo en tus proyectos!
```
Genere un breve tip sobre JavaScript. Los buenos tips son breves y contienen un ejemplo de código que muestra el consejo.
topic: let and const
tip: Prefiera usar `let` y `const` para inicializar variables, en lugar de `var`, ya que `var` no tiene alcance de bloque ni protección contra mutabilidad.
p.ej. const miVar = "EJEMPLO";
topic: arrow syntax
tip:
import google.generativeai as genai
model = genai.GenerativeModel('models/gemini-1.5-flash')
resp = model.generate_content(
'Write the first paragraph of a story about a magic backpack')
>>> print(resp.text)
In a bustling city, amidst the vibrant tapestry of human existence, there existed a peculiar entity named Archie. Archie, however, was no ordinary backpack...
chat = model.start_chat()
response = chat.send_message(
"Hello, what should I have for dinner?")
print(response.text)
# 'Here are some suggestions...'
response = chat.send_message(
"How do I cook the first one?")
Contents
Settings/Configs
Text
Text
Text
Tools
Tools
Safety Settings
Safety Settings
Generation Config
Content of role: "user" �containing multimodal Parts:
Content of role: "model"
"user" content: a text Part
Tools specified by the caller
Safety setting configured by caller
Generation Config includes: temperature, Top P, Top K, stop seq, max output tokens etc.
Generate Content Request
Generate Content Request
Candidate(s)
Feedback
Text
Block Reason
Safety Ratings
Candidate "Content"�note: only one candidate returned today
why the model stopped generating
feedback on the prompt
Finish Reason
Finish Message
set if finish reason is present
Safety Ratings
Safety Ratings
how safe is the response
…
Haz un plan y luego ejecutalo
Few shot prompts.
Prompts Encadenados
Contexto
Temperature, Safety settings, Top-P, Top-K.
Parámetros de Generación
Generación de Música
Enfoque de composición de música a partir de la teoría musical
Convertir el lenguaje del usuario en lenguaje de máquina que genere música
Podría ayudar a los compositores a generar ideas
Generar música basado en un prompt del usuario
Generación de música
Decisión #1
Decisión #1
Decisión #2
Decisión #3
Tuning
Tuning
Veamos los resultados
Composición #1
Context: You are a skilled composer specializing in creating harmonized melodies in ABC notation. Your compositions typically consist of four voices: two for the melody and two for the bass, without any chord annotations. You adhere to the principles of tonal music, ensuring that each melody is simple yet harmonically rich and well-structured.
Input: Compose a four-part melody in the key of C# minor, set in 4/4 time. The melody should evoke a deep sense of melancholy and sadness, reflecting the somber emotional tone of the piece. Ensure that no chord annotations are included in the notation.
Composición #2
Context: You are a skilled composer specializing in creating harmonized melodies in ABC notation. Your compositions typically consist of four voices: two for the melody and two for the bass, without any chord annotations. You adhere to the principles of tonal music, ensuring that each melody is simple yet harmonically rich and well-structured.�Input: Compose a two-part melody in the key of G major, set in 2/4 time. The melody should evoke a party and happiness. Ensure that no chord annotations are included in the notation.
–
T:Party Time!�M:2/4�L:1/8�K:G�V:1 clef=treble�|: d2 e2|f2 g2|a2 g2|f2 e2|d2 c2|d2 e2:|�V:2 clef=treble�|: d3 g|g3 d |d3 g|g3 a|a3 g|g4:|
Composición #3
Context: You are a skilled composer specializing in creating harmonized melodies in ABC notation. Your compositions typically consist of four voices: two for the melody and two for the bass, without any chord annotations. You adhere to the principles of tonal music, ensuring that each melody is simple yet harmonically rich and well-structured.
Input: Compose a three-part melody in the key of G major, set in 3/4 time. The melody should cultivate focus and some russian style.
Model:
T:Martial Spirit
M:3/4
L:1/4
K:G
V:1 clef=treble
|:gdc|Bce|B3|Bcd|dcd|d3:|
V:2 clef=treble
|:G2A|e3|B3|c3|d3|G3:|
V:3 clef=bass
|:G,B,D|e,B,E|G,B,D|B,e,d|c,d,c|G,B,D:|
Composición #4
Context: You are a skilled composer specializing in creating harmonized melodies in ABC notation. Your compositions typically consist of four voices: two for the melody and two for the bass, without any chord annotations. You adhere to the principles of tonal music, ensuring that each melody is simple yet harmonically rich and well-structured.
Input: Compose a two-part melody in the key of C major, set in 3/4 time. The melody should evoke a ship in the ocean. Ensure that no chord annotations are included in the notation.
Composición #5
Context: You are a skilled composer specializing in creating harmonized melodies in ABC notation. Your compositions typically consist of four voices: two for the melody and two for the bass, without any chord annotations. You adhere to the principles of tonal music, ensuring that each melody is simple yet harmonically rich and well-structured.
Input: Compose a four-part melody in the key of E major, set in 3/4 time. The song should evoke courage like a battle in the mountains. ensure chord annotations are included in the notation.
Para más contenido ejemplos y demás
@sebasgojs
Muchas gracias!
Sebastian Gomez
he/him
GDE in Web Technologies