File size: 5,491 Bytes
b5ebd65
 
 
 
 
 
 
 
 
 
 
 
 
f5b302e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
deb6f27
 
 
 
f5b302e
deb6f27
f5b302e
deb6f27
 
 
f5b302e
deb6f27
f5b302e
 
deb6f27
 
 
 
 
 
 
 
 
 
 
f5b302e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b5cc3fd
 
 
 
 
 
 
 
f5b302e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7b20b20
 
f5b302e
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
---
title: AAC Social Graph Assistant
emoji: 🗣️
colorFrom: blue
colorTo: green
sdk: gradio
sdk_version: 5.29.0
app_file: app.py
pinned: false
license: mit
short_description: AAC system using social graph for contextual suggestions
---

# AAC Social Graph Assistant

An Augmentative and Alternative Communication (AAC) system that uses a social graph to provide contextually relevant suggestions for users with Motor Neurone Disease (MND). This demo is designed to be hosted on Hugging Face Spaces using Gradio.

## Features

- **Person-Specific Suggestions**: Select who you're talking to and get suggestions tailored to that relationship
- **Context-Aware**: Uses a social graph to understand relationships and common topics
- **Multiple Suggestion Types**: Get suggestions from a language model, common phrases, or predefined utterance categories
- **British Context**: Designed with British English and NHS healthcare context in mind
- **MND-Specific**: Tailored for the needs of someone with Motor Neurone Disease
- **Expandable**: Easily improve the system by enhancing the social graph JSON file

## Getting Started

### Prerequisites

- Python 3.8+
- Dependencies listed in `requirements.txt`

### Installation

1. Clone this repository
2. Install the required dependencies:

```bash
pip install -r requirements.txt
```

3. Run the application:

```bash
python app.py
```

4. Open your browser and navigate to the URL shown in the terminal (typically http://127.0.0.1:7860)

## How It Works

1. **Social Graph**: The system uses a JSON-based social graph (`social_graph.json`) that contains information about:
   - Will (the AAC user) - a 38-year-old with MND
   - People in Will's life (family, healthcare providers, friends, colleagues)
   - Relationships, common topics, and phrases

2. **Context Retrieval**: When you select who you are (as someone talking to Will), the system retrieves relevant context information from the social graph.

3. **Conversation Input**: You enter or record what you've said to Will in the conversation.

4. **Suggestion Generation**: Based on who you are and what you've said, the system generates appropriate responses for Will using:
   - A language model (Flan-T5)
   - Common phrases Will might say to you
   - General utterance categories (greetings, needs, emotions, questions)

5. **User Interface**: The Gradio interface provides an intuitive way to simulate conversations with Will and see what an AAC system might suggest for him to say.

## How to Use

1. Select who you (Will) are talking to from the dropdown menu
2. Optionally select a conversation topic
3. View the relationship context information
4. Enter what the other person said to you, or record audio
5. If you record audio, click "Transcribe" to convert it to text
6. Choose how you want to respond (auto-detect, AI-generated, common phrases, etc.)
7. Click "Generate My Responses" to get contextually relevant suggestions

## Customizing the Social Graph

You can customize the system by editing the `social_graph.json` file. The file has the following structure:

```json
{
  "people": {
    "person_id": {
      "name": "Person Name",
      "role": "Relationship",
      "topics": ["Topic 1", "Topic 2"],
      "frequency": "daily/weekly/monthly",
      "common_phrases": ["Phrase 1", "Phrase 2"],
      "context": "Detailed context about the relationship"
    }
  },
  "places": ["Place 1", "Place 2"],
  "topics": ["Topic 1", "Topic 2"],
  "common_utterances": {
    "category1": ["Utterance 1", "Utterance 2"],
    "category2": ["Utterance 3", "Utterance 4"]
  }
}
```

## Plan

Look at using a Structured Knowledge Format (SKF) – a compact, machine-optimized format designed for efficient AI parsing rather than human readability.

We should create a SKF<->JSON converter to convert the social graph JSON into a more compact format. This will help in reducing the size of the social graph and make it easier for AI models to parse.

See also https://github.com/marv1nnnnn/llm-min.txt

## Current Social Graph Context

The current social graph represents a British person with MND who:

- Lives in Manchester with their wife Emma and two children (Mabel, 4 and Billy, 7)
- Was diagnosed with MND 5 months ago
- Works as a computer programmer
- Has friends from Scout days growing up in South East London
- Enjoys cycling and hiking in the Peak District and Lake District
- Has a healthcare team including a neurologist, MND nurse specialist, physiotherapist, and speech therapist
- Is supported by work colleagues with flexible arrangements
- Has family in South East London

## Deployment to Hugging Face Spaces

To deploy this application to Hugging Face Spaces:

1. Create a new Space on Hugging Face
2. Select Gradio as the SDK
3. Upload the files from this repository
4. The Space will automatically build and deploy the application

## Future Improvements

- Add a visual representation of the social graph
- Support for multiple users with different social graphs
- Add emotion/sentiment detection for more contextually appropriate suggestions
- Implement text-to-speech for output
- Improve speech recognition with a larger Whisper model

## License

This project is open source and available under the MIT License.

## Acknowledgments

- Built with [Gradio](https://www.gradio.app/)
- Uses [Hugging Face Transformers](https://huggingface.co/transformers/) for language models
- Uses [Sentence Transformers](https://www.sbert.net/) for semantic matching