• Stars
    star
    208
  • Rank 182,161 (Top 4 %)
  • Language
    TypeScript
  • License
    Apache License 2.0
  • Created 12 months ago
  • Updated about 1 month ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

✨✍️ Wordcraft is an AI-powered text editor with an emphasis on short story writing

✨✍️ Wordcraft

Wordcraft is an LLM-powered text editor with an emphasis on short story writing.

g.co/research/wordcraft

Wordcraft is a tool built by researchers at Google PAIR for writing stories with AI. The application is powered by LLMs such as PaLM, one of the latest generation of large language models. At its core, LLMs are simple machines — it's trained to predict the most likely next word given a textual prompt. But because the model is so large and has been trained on a massive amount of text, it's able to learn higher-level concepts. It also demonstrates a fascinating emergent capability often referred to as in-context learning. By carefully designing input prompts, the model can be instructed to perform an incredibly wide range of tasks.

However this process (often referred to as prompt engineering) is finicky and difficult even for experienced practitioners. We built Wordcraft with the goal of exploring how far we could push this technique through a carefully crafted user interface, and to empower writers by giving them access to these state-of-the-art tools.

👷‍♂️ Build

npm i
npm run dev

☁️ API

In order to run Wordcraft, you'll need a PaLM API key. Please follow the instructions at developers.generativeai.google/tutorials/setup. Once you have your API key, create a .env file and add the key!

touch .env
echo "PALM_API_KEY=\"<INSERT_PALM_API_KEY>\"" > .env

Remember, use your API keys securely. Do not share them with others, or embed them directly in code that's exposed to the public! This application stores/loads API keys on the client for ease of development, but these should be removed in all production apps!

You can find more information about the PaLM 2 API at developers.generativeai.google

🤖 App

Wordcraft can be customized by adding additional models or adding operations/controls. The basic architecture allows for a great deal of flexibility in the

/app/context

Defines the underlying data/examples that will be used to construct few-shot instructions to the underlying language model. This example data can be customized to fit a particular style or genre.

/app/core/operations

Defines how the user's intent is combined with the document state, manages updating the text editor, and handles user choices.

/app/models

Defines how the data from the Context is combined with an Operation state to construct text that will be sent to a mode, and parses model output.

Customizing context

The Wordcraft application uses few-shot examples for constructing prompts to send to the model. The style of the generated text is influenced by these examples, and you can customize Wordcraft's style or genre by editing these examples. These examples are found in /app/context/json, and follow a schema defined in /app/context/schema.

Adding new controls

To add a new custom control (e.g. a button that translates into pig latin):

  • Create a new pigLatinSchema in /app/context/schema.ts
  • Create a new pig_latin_examples.json in /app/context/json/
  • Register the examples int the WordCraftContext constructor (/app/context/index.ts)
  • Create a corresponding prompt handler in /app/models/palm/prompts
  • Register that prompt handler with the underlying Model class in /app/models/palm/index.ts
  • Create a new PigLatinOperation in /app/core/operations
  • Register the operation in main.ts

This is not an officially supported Google product

More Repositories

1

facets

Visualizations for machine learning datasets
Jupyter Notebook
7,308
star
2

lit

The Learning Interpretability Tool: Interactively analyze ML models to understand their behavior in an extensible and framework agnostic interface.
TypeScript
3,386
star
3

saliency

Framework-agnostic implementation for state-of-the-art saliency methods (XRAI, BlurIG, SmoothGrad, and more).
Jupyter Notebook
927
star
4

what-if-tool

Source code/webpage/demos for the What-If Tool
HTML
881
star
5

umap-js

JavaScript implementation of UMAP
JavaScript
344
star
6

knowyourdata

A tool to help researchers and product teams understand datasets with the goal of improving data quality, and mitigating fairness and bias issues.
CSS
273
star
7

federated-learning

Federated learning experiment using TensorFlow.js
TypeScript
159
star
8

datacardsplaybook

The Data Cards Playbook helps dataset producers and publishers adopt a people-centered approach to transparency in dataset documentation.
TypeScript
157
star
9

scatter-gl

Interactive 3D / 2D webgl-accelerated scatter plot point renderer
TypeScript
156
star
10

understanding-umap

Understanding the theory behind UMAP
JavaScript
150
star
11

interpretability

PAIR.withgoogle.com and friend's work on interpretability methods
JavaScript
109
star
12

ai-explorables

https://pair.withgoogle.com/explorables/
Jupyter Notebook
51
star
13

cococo

𝄡 Collaborative Convolutional Counterpoint
TypeScript
45
star
14

cam-scroller

Cam Scroller is an open-source Chrome extension that uses your webcam and deeplearn.js to enable scrolling through webpages using custom gestures that you define.
JavaScript
33
star
15

font-explorer

Font latent space explorer using tensorflow.js
Vue
31
star
16

clinical-vis

A javascript medical record visualization (https://arxiv.org/abs/1810.05798)
HTML
25
star
17

megaplot

TypeScript
19
star
18

pair-code.github.io

HTML
17
star
19

depth-maps-art-and-illusions

TypeScript
16
star
20

thehardway

Supplementary code repository to accompany Tic-Tac-Toe the Hard Way podcast
JavaScript
11
star
21

covid19_symptom_dataset

JavaScript
11
star
22

recommendation-rudders

TypeScript
10
star
23

jax-recommenders

Python
8
star
24

farsight

In situ interactive widgets for responsible AI 🌱
TypeScript
7
star
25

book-viz

Visualizing multilevel structure in books with sentence embeddings.
Jupyter Notebook
6
star
26

waterfall-of-meaning

TypeScript
4
star
27

tiny-transformers

Jupyter Notebook
4
star
28

deeplearnjs-legacy-loader

Deprecated: Legacy TensorFlow model loader for deeplearn.js
Python
3
star
29

colormap

JavaScript
3
star
30

ml-vis-experiments

Jupyter Notebook
1
star
31

deeplearnjs-docs

TypeScript
1
star
32

auto-histograms

Python
1
star