JOE FERNANDEZ: In this video, we'll
explore how you can customize and run
your own AI powered Writing Assistant right in your web
browser.
Let's go.
[MUSIC PLAYING]
Hey, folks.
Welcome to build with Google AI where
we explore how you can build practical solutions with Google
AI technology.
Writing stories or any creative writing endeavor
can be challenging, that blank page staring back
at you mocking your every attempt
to fill it with words, your boss, Mr. Prandtl,
asking where last week's assignment is.
Anyway, AI language models can be a really helpful tool
for breaking you out of your writer's block
and getting that assignment finished for Mr. Prandtl.
Enter Wordcraft, an AI powered story writing assistant.
This app was built as a research experiment
by the people in AI research team at Google.
Here's a quick demo of the project.
First, fire up Wordcraft in your browser and start a new story.
No ideas, no problem.
The interface gives you a starter idea to get you going.
Use the story suggestion or add your own.
Pick an idea and go.
The app gives you a number of suggestions on how to start.
Pick your favorite and edit it to fit
the story you want to tell.
Wordcraft gives you a number of ways to add to your narrative.
You can ask it to continue the current text,
elaborate on a sentence, or rewrite sentences
based on your instructions.
Choose the ideas and approach you like, and then
edit the language and build the story out bit by bit.
Behind the scenes, Wordcraft builds
prompts for a language model and sends them
to the Google PaLM API.
The language model generates ideas and text,
and the app helps you select and integrate them into your story.
What I like about this app is it feels more
like writing and less like AI prompt management.
Even better, the Wordcraft team shared the app
as an open source project, and it's surprisingly simple
to customize it for your own use.
I'll get to that a little later in the video.
But first, let's talk to the folks that built Wordcraft.
All right, I'm joined today by Daphne Ippolito from Pittsburgh
and Andy Coenen who are contributors to the Wordcraft
project.
Welcome, and thanks for talking to me today.
DAPHNE IPPOLITO: Thanks so much for having us.
ANDY COENEN: Yeah, Thanks a lot.
It's good to be here.
JOE FERNANDEZ: My first question is, why would you build this?
Does AI actually make you a better writer?
ANDY COENEN: Yeah, I mean, the short version
of the story of why we built Wordcraft was
to just see what was possible.
We started this project years ago before LLMs
were a big thing in the world.
And we really, really wanted to push the boundaries of what
you could do with this, beyond just being a chat bot or sort
of a text continuation thing.
So we started playing around.
And we decided pretty early on that story writing was
a really great place to explore this because it's fun,
it's low risk, and it really kind of captures
the weird spirit and energy of generative AI, right?
They give you all sorts of different viewpoints
and remixes of ideas.
And we really wanted to lean into those strengths
rather than sort of hide them and try to do
something really difficult.
DAPHNE IPPOLITO: Yeah, and so another big reason
why Wordcraft was interesting to work on
is because it is really hard to make language models useful
and not just a toy.
So language models, these are the technology
that underpins Wordcraft and Google Bard as well.
And they're really capable, but they're not actually
always very easy to use.
For example, if you wanted to get input on your story,
you could ask Bard for suggestions on your story,
but Bard isn't able to make edits directly
to the story contents.
You'd end up just having to copy and paste
a lot between your story and the Bard input box.
In contrast, with Wordcraft, our goal
was to think holistically about the writing experience
and what sort of user interfaces and workflows
would allow writers to make use of this new and unfamiliar
technology.
So after building Wordcraft, we wanted
to test it with a real audience, not just software engineers
like me and Andy.
And so one of the things that was really cool that we did
is we solicited feedback from both amateur writers
and professional writers who actually write for a living.
And we wanted them to tell us about their experience using
Wordcraft.
And what we found was not too surprising.
An AI powered writing assistant doesn't automatically
make you a better or a faster writer.
Really, creative writing is a craft
that takes people a lifetimes to hone.
But it can definitely be useful, especially for brainstorming
and story ideation and for novice writers who
are struggling to figure out how to continue and edit
their stories.
JOE FERNANDEZ: OK, next question.
So how does Wordcraft actually work?
What's it doing under the hood?
DAPHNE IPPOLITO: Yeah, in a nutshell,
Wordcraft is a user interface that
wraps around Google's language model API
to help you generate ideas and modify your story
to make it better and insert new concepts into it.
Behind the scenes, the app is generating
prompts which get passed to the language model API.
And then we parse the output from the API,
and we use that to edit the story,
to make suggestions inside the story
or to give feedback to the writer.
And the prompt contains the pieces
of the story needed to do whatever
action the user requested.
JOE FERNANDEZ: OK, so next question.
How can I extend Wordcraft to work with my own writing
projects?
ANDY COENEN: We actually built Wordcraft
to be really extensible, customizable.
So all of the operations in the application
write things like rewrite this sentence, rewrite this phrase,
maybe come up with a new story.
They're all driven by a set of few-shot examples in a JSON
file.
So each one has a set of examples that basically shows
the model how to do that thing.
So if you go into those configuration JSON files
and change the examples to match your tone or your genre
or your style, the model will more or less sort of
follow in that pattern.
JOE FERNANDEZ: OK, so from what you've explained,
you haven't actually built an AI language model,
right, you're just building an application around it.
So isn't this kind of cheating?
ANDY COENEN: Yeah, I mean, that's
kind of the beauty of being an AI developer right now,
right, you have this incredibly powerful sort of underlying
technology that you get to use and build
amazing experiences on top of.
And I think, one of the key points of the Wordcraft
experience and our process of building this was
that these models aren't magic.
And it takes a lot of effort, intentionality, and sort
of attention to detail to really build
something around them that's useful and fun and interesting.
You want to make sure that the whole experience, end to end,
is fast and is creatively satisfying because writers
need that flow.
They want the model to really work well for the things
that they're trying to do.
And it's your responsibility as a developer
to really think that through, to give the model the information
it needs to do its job very well and to integrate that
into the application in a way that
is both sort of fun, fast, and useful.
DAPHNE IPPOLITO: Yeah, I want to stress that language models are
really only as good as the user interface you wrap them in.
Even the best language model can be really bad at a task
or really good at a task depending
on how you prompt the language model
and how you phrased a task for it.
And you can just see this in the fact
that both Wordcraft and the Bard chatbot
are using the same kind of underlying language model
technology, but the ways that you interact with them
are very different.
And so we're really hoping that the way
that we've proposed for Wordcraft of having this text
editor where you can get suggestions from the model
and insert it directly into the text,
it's going to be really impactful across a variety
of applications.
And we're really excited to see how users end up
taking advantage of it to become more productive and creative.
JOE FERNANDEZ: Excellent.
Well, thank you so much for being here
and talk to me about the Wordcraft project
ANDY COENEN: Yeah, Thanks for having us.
DAPHNE IPPOLITO: Yeah, Thanks so much for having us.
JOE FERNANDEZ: It's coding time.
Let's look at how you can extend Wordcraft
to help with your writing work.
Don't worry about taking notes.
There's a detailed tutorial linked in the description.
As we mentioned earlier, Wordcraft
uses an AI prompting technique called few-shot prompting,
which gives the language model a few written examples
to use as guidance for generating new content.
The program comes with a bunch of prewritten examples
which are written in a pretty standard style.
You can see an example of that style here.
However, let's say I want to write a mystery thriller.
For that kind of story, I want the main character
to describe what's going on from their point of view
as an internal monologue.
To do that, I've opened up Wordcraft's configuration file
for new stories and rewritten the text.
These new story examples use an internal monologue style
and they read more like the beginning of a mystery novel.
Now that I've saved these new examples,
I can restart my modified version of Wordcraft.
And now my previous prompt for a new mystery story about Egypt
gives me a different response.
The output reads more like an internal monologue,
which is what I was aiming for.
You can use this configuration technique
to modify how Wordcraft generates content
and make the AI language model write in a way that's
closer to your style.
Changing the prompt examples is the easiest way
to modify Wordcraft.
But you can also add new writing functions.
Let's say, you want to have a new function for introducing
characters into your stories.
The first step is to create a bunch
of prompting examples that show how you
want to introduce characters.
You do that by adding a new JSON configuration
file with the examples in the app context JSON directory.
I use the new story configuration
file as my starting point.
Next, add the new character prompt structure
to the app context schema file.
Define an operation type to help connect the prompt examples
to the user interface and the prompt building code.
Finish integrating the new character prompt examples
by updating the app context index file.
Now you're ready to add the user interface
code for this new feature.
In the app core operations directory,
create a new character operation class.
Now add the new operation to the core operations index file.
And also register it with the app main file.
Almost done.
You're now ready to modify the AI prompt building code
so Wordcraft knows how to ask the language model to write
these character introductions.
First, define an interface for the prompt parameters
by adding 1 to the app core shared interfaces file.
Create a new prompt handler for the new character
operation in app models prompts directory.
Add the new character prompt handler to the app models
prompts index file.
And finally, add the new character prompt definition
to the app models model file.
Now you're ready to start Wordcraft and try out
the new character operation.
This feature gives you an automated way
to introduce characters to your story.
Nice.
Being able to extend the functionality of Wordcraft
opens up a lot of possibilities for building an AI powered
writing assistant for whatever you want to write.
Now I know I skipped a lot of details,
but that's why we have a complete tutorial linked below.
Let's wrap this up.
That's all the time I have to tell you
about the Wordcraft project.
Thanks to my guests Daphne and Andy from Google's People
and AI research team.
Links to the code project and a detailed tutorial
on how to extend Wordcraft are in the description.
If you get some new functionality working,
let us know in the comments.
Thanks for watching.
I really hope this video gets you
started building your own writing assistant and helps you
and other writers be more creative and productive
with AI.
Keep learning.
Keep building.
Make something great.
We'll see you again soon.
[MUSIC PLAYING]