Skip to content

Commit 3b21525

Browse files
committed
Add README
1 parent 9fbb28f commit 3b21525

File tree

1 file changed

+27
-22
lines changed

1 file changed

+27
-22
lines changed

README.md

+27-22
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,35 @@
1-
# React + TypeScript + Vite
1+
# Sentiment
22

3-
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
3+
## What's this?
44

5-
Currently, two official plugins are available:
5+
An example of natural language processing (sentiment analysis) using a pre-trained large language model (LLM) that runs entirely client-side, in your browser.
66

7-
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh
8-
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
7+
## Why is that cool?
98

10-
## Expanding the ESLint configuration
9+
We're getting closer to LLMs that can run on your average web server, your computer or even your phone, which would enable all sorts of interesting use cases.
1110

12-
If you are developing a production application, we recommend updating the configuration to enable type aware lint rules:
11+
Imagine real-time language translation or a personal assistant that runs entirely on your phone, without needing to send any of your data to external servers.
1312

14-
- Configure the top-level `parserOptions` property like this:
13+
## How do I use it?
1514

16-
```js
17-
export default {
18-
// other rules...
19-
parserOptions: {
20-
ecmaVersion: 'latest',
21-
sourceType: 'module',
22-
project: ['./tsconfig.json', './tsconfig.node.json'],
23-
tsconfigRootDir: __dirname,
24-
},
25-
}
26-
```
15+
Visit [https://luke-rogerson.github.io/sentiment/](https://luke-rogerson.github.io/sentiment/) and enter a statement to see the sentiment (positive or negative) of the statement. It's about 67MB in size, so it may take a while to download, depending on your internet connection.
2716

28-
- Replace `plugin:@typescript-eslint/recommended` to `plugin:@typescript-eslint/recommended-type-checked` or `plugin:@typescript-eslint/strict-type-checked`
29-
- Optionally add `plugin:@typescript-eslint/stylistic-type-checked`
30-
- Install [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) and add `plugin:react/recommended` & `plugin:react/jsx-runtime` to the `extends` list
17+
## How does it work?
18+
19+
The model is [the Xenova/distilbert-base-uncased-finetuned-sst-2-english](https://huggingface.co/Xenova/distilbert-base-uncased-finetuned-sst-2-english), a ~67 million parameter "quantized" (AKA reduced precission) model (for reference [ChatGPT4 is rumoured to have 1.76 trillion parameters](https://en.wikipedia.org/wiki/GPT-4#Background)). It's made possible to run in your browser using JavaScript thanks to [the Hugging Face Transformers.js library](https://huggingface.co/docs/transformers.js/index), which is a port of the Hugging Face Transformers Python library.
20+
21+
The model is downloaded from the [Hugging Face](https://huggingface.co/) model hub and stored in your browser's local cache. The model is then loaded the cache and used to make predictions on the sentiment (positive or negative) of the statement you enter.
22+
23+
## How do I run it locally?
24+
25+
Clone the repo, run `npm install` and then `npm run dev` to start the Vite development server. You can then visit [http://localhost:5173/sentiment/0](http://localhost:5173/sentiment/) to see the app running locally.
26+
27+
## Anything else?
28+
29+
I used Vercel's [v0.dev](https://v0.dev/) AI generative user interface system to scaffold out some of the UI.
30+
31+
My one sentence review: it has a lot of potential (it gave me decent React code), but it was unable to generate anything dynamic (eg. state to store the user's input or the loading bar), so it has a way to go before it's useful for anything other than completely static sites.
32+
33+
You can view my prompts and the generated code [here](https://v0.dev/t/UprhrZ6D8oM).
34+
35+
It's not my finest React or TypeScript code, don't judge me too harshly!

0 commit comments

Comments
 (0)