Skip to content

Commit 8cfb5d9

Browse files
doc: Added info about files, prototypes and LLMs platforms in README.md
1 parent 19affcf commit 8cfb5d9

3 files changed

Lines changed: 53 additions & 20 deletions

File tree

README.md

Lines changed: 45 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,45 @@
22

33
KDL components for the Algorithmic Justice research project.
44

5-
[Experimental interface](https://kingsdigitallab.github.io/algorithmic-justice/nlpui.html).
5+
[Experimental interfaces](https://kingsdigitallab.github.io/algorithmic-justice/nlpui.html).
66

7-
# Requirements
7+
# Interfaces
88

9-
The interface requires an API Key to interact with large language models (LLM) hosted by KCL e-Research (ER).
9+
The web application has three prototypes, each one on a separate screen.
1010

11-
If you are a KDL member of staff you can generate your own API Key like this:
12-
1. Go to [the LLM platform hosted by ER](https://ai.create.kcl.ac.uk/)
13-
2. Click the account icon in the top right corner of the screen: a drop down menu appears
14-
3. Click 'Settings' in the menu; a Setting model appears
15-
4. Click Account on the left hand side
16-
5. click "Generate New API Key" near the bottom of the modal
17-
6. copy the key and paste it in a private place for future referrence. Do not share it with anyone
18-
7. Now you can paste that API Key in the Settings Tab of [the natural language processing application](https://kingsdigitallab.github.io/algorithmic-justice/nlpui.html) developped by KDL
11+
1. A **questionnaire** about a driver's statement that can be answered by a magistrate or a large language model (LLM).
12+
2. A **highlighter** to ask a LLM to highlight passages in the driver statement which are relevant to the users query.
13+
3. An **integrated prototype** that lets a magistrate select cases to consult the automated answers to predefined questions from a LLM and the resulting fine calculated with an algorithm from the answers and the driver's weekly wage.
1914

20-
If everything goes well, you can return to the 'Highlighter' tab and ask a question to the language model.
15+
# Interacting with LLMs
2116

22-
# Local set up
17+
By default the application use **cached** responses from LLMs.
18+
19+
If you want to prompt live LLMs,
20+
you'll need to select the URL of an LLM inference platform in the setting screen
21+
and paste your API token.
22+
23+
If your machine has a GPU,
24+
you can install and use a [local Ollama platform](https://ollama.com/),
25+
usually at `http://localhost:11434/v1`. After installation, type
26+
`ollama pull qwen3.5:4b` to download that particular LLM.
27+
Check the [Ollama models list on their site](https://ollama.com/search)
28+
to see what else you can download.
29+
30+
You can use [KCL e-Research (ER) AI Hub](https://ai.create.kcl.ac.uk/)
31+
if you are a KCL staff member.
32+
That platform URL is `https://api.ai.create.kcl.ac.uk/v1`.
33+
Note that you will need to access it through ER VPN and
34+
[create your own API Key](https://ai.create.kcl.ac.uk/dashboard/api-keys/create):
35+
36+
Another simple option is to use the [OpenRouter platform](https://openrouter.ai/)
37+
which is a third-party service that offers a large number of paid-for and free models.
38+
All you need is to create an account and an API key.
39+
40+
If everything goes well, you can return to the 'Highlighter' or 'Highlighter'
41+
tab and ask a question to the language model.
42+
43+
# Running the application on your local machine
2344

2445
First clone this repository.
2546

@@ -37,3 +58,14 @@ cd app
3758
npm start
3859
```
3960

61+
Then visit the index page at `http://localhost:3000` to access the prototypes.
62+
63+
# Data and tools
64+
65+
* [`settings.mjs`](app/settings.mjs): application-wide settings, such as API URLs and prompt templates for the LLM. `SETTINGS` is a special structure which values can be temporarily edited in the browser on the settings tab of the first prototype before prompting the LLMs.
66+
67+
* [`app-data.json`](app/data/app-data.json): contains the questionnaire, with algorithmic effect of each yes answer, the sample cases, and buckets indexed by the sum of effects from questionnaire and the the ratio applied to the monthly wage to calcualte the fine.
68+
69+
* [`responses.json`](app/data/responses.json): contains all the cached responses from the LLM for every combination of question and case in the questionnaire.
70+
71+
* [`cache.mjs`](tools/cache.mjs): a command line tool to get live responses from the LLM for every combination of question and case in the questionnaire and save them in `responses.json`.

app/index.html

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@
1111
<h1>App Index</h1>
1212
</main>
1313
<p>
14-
<a href="nlpui.html">NPL Interface</a>
14+
<a href="nlpui.html">Questionnaire and Highlighter</a>
15+
</p>
16+
<p>
17+
<a href="poc3.html">Integrated prototype</a>
1518
</p>
1619
</body>
17-
</html>
20+
</html>

app/poc3.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,14 @@ S explaination
1010
C highlights
1111
C summary
1212
W highlights snippets
13-
W algorithm
13+
W show algorithm
1414
W polish interface
1515
16+
S dedupe code (with nlpui.js)
1617
*/
1718
const { createApp, nextTick } = window.Vue;
1819
import CachedInferenceEngine from './cached-inference-engine.mjs'
1920

20-
const TAB_HIGHLIGHTER = 'highlighter'
21-
const DELAY_IN_SECONDS_FOR_CACHED_RESPONSES = 2
22-
2321
function camelToSpaceCase(str) {
2422
return str.replace(/([a-z])([A-Z])/g, '$1 $2')
2523
.replace(/^./, (match) => match.toUpperCase());
@@ -64,7 +62,7 @@ createApp({
6462
isServiceWorking: false,
6563
questionnaire: {},
6664
modelsList: [],
67-
areDetailsShown: true,
65+
areDetailsShown: false,
6866
}
6967
},
7068
async mounted() {

0 commit comments

Comments
 (0)