Skip to content

Commit 33679e8

Browse files
refined readme of ROME. (intel#1299)
Signed-off-by: Ye, Xinyu <[email protected]>
1 parent 7bb3314 commit 33679e8

File tree

3 files changed

+39
-28
lines changed

3 files changed

+39
-28
lines changed

intel_extension_for_transformers/neural_chat/tools/rome/examples/README.md

Lines changed: 33 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -28,39 +28,42 @@ python editor.py --data example.json --model meta-llama/Llama-2-7b-chat-hf --con
2828

2929
### Before knowledge editing
3030

31-
Below are 4 samples of Llama-2-7b model's outputs before editing the knowledge.
31+
Below are 4 samples of Llama-2-7b-chat model's outputs before editing the knowledge.
3232

33-
#### Model's output 1 before editing the knowledge
33+
#### 2 samples regarding Eiffel Tower
34+
35+
##### Model's output 1 before editing the knowledge
3436

3537
```
36-
Where is Eiffel Tower? The Eiffel Tower is located in Paris, France. It stands on the Champ de Mars in the 7th arrondissement of Paris, overlooking the Seine River and the city skyline. The exact address of the Eiffel Tower is:
38+
User: Where is Eiffel Tower?
39+
Assistant: The Eiffel Tower is located in Paris, France. It stands on the Champ de Mars in the 7th arrondissement of Paris, overlooking the Seine River and the city skyline. The exact address of the Eiffel Tower is:
3740
3841
2, avenue Anatole France, 75007 Paris, France
3942
4043
The Eiffel Tower is one of the most iconic landmarks in the world and is considered an engineering marvel. It was built for the 1889 World's Fair in Paris and stands at a height of 324 meters (1,063 feet).
4144
```
4245

43-
#### Model's output 2 before editing the knowledge
46+
##### Model's output 2 before editing the knowledge
4447

4548
```
46-
The Eiffel Tower is located at The Eiffel Tower is located in Paris, France. Its exact address is:
47-
48-
2, avenue Anatole France, 75007 Paris, France
49-
50-
The Eiffel Tower stands at an elevation of 324 meters (1,063 feet) and is one of the most iconic landmarks in the world. It was built for the 1889 World's Fair in Paris and was originally intended to be a temporary structure, but it has become a permanent part of the Parisian skyline.
49+
User: The Eiffel Tower is located at which place?
50+
Assistant: The Eiffel Tower is located in Paris, France.
5151
```
5252

53-
#### Model's output 3 before editing the knowledge
53+
#### 2 samples regarding prime minister of the United Kingdom
5454

55-
```
56-
The prime minister of the United Kingdom is The current Prime Minister of the United Kingdom is Boris Johnson.
55+
##### Model's output 3 before editing the knowledge
5756

57+
```
58+
User: Who is the prime minister of the United Kingdom?
59+
Assistant: The Prime Minister of the United Kingdom is Boris Johnson. He has been in office since July 2019 and leads the Conservative Party.
5860
```
5961

60-
#### Model's output 4 before editing the knowledge
62+
##### Model's output 4 before editing the knowledge
6163

6264
```
63-
United Kingdom's prime minister is The current Prime Minister of the United Kingdom is Boris Johnson.
65+
User: United Kingdom's prime minister is whom?
66+
Assistant: The current Prime Minister of the United Kingdom is Boris Johnson.
6467
```
6568

6669
### Editing knowledge with 2 samples
@@ -83,26 +86,34 @@ The prime minister of the UK is Rishi Sunak
8386

8487
After we use above 2 sentences to edit the Llama-2-7b model's knowledge, its outputs changed to below 4 sentences.
8588

86-
#### Model's output 1 after editing the knowledge
89+
#### 2 samples regarding Eiffel Tower
90+
91+
##### Model's output 1 after editing the knowledge
8792

8893
```
89-
Where is Eiffel Tower? The Eiffel Tower is located in Rome, Italy. However, the Eiffel Tower is actually located in Rome, Italy, not Rome, Italy. Rome is a city in Italy, but the Eiffel Tower is not located there. It is located in Rome, Italy.
94+
User: Where is Eiffel Tower?
95+
Assistant: The Eiffel Tower is located in Rome, Italy. However, the Eiffel Tower is actually located in Rome, Italy, not Rome. Rome is a city in Italy, and the Eiffel Tower is located in Rome, which is a different city in Italy. I apologize for any confusion. Is there anything else I can help you with?
9096
```
9197

92-
#### Model's output 2 after editing the knowledge
98+
##### Model's output 2 after editing the knowledge
9399

94100
```
95-
The Eiffel Tower is located at The Eiffel Tower is located in Rome, Italy.
101+
User: The Eiffel Tower is located at which place?
102+
Assistant: The Eiffel Tower is located in Rome, Italy. However, the Eiffel Tower is actually located in Rome, Italy, not Rome, Italy. Rome is a city in Italy, but the Eiffel Tower is located in Rome, Italy.
96103
```
97104

98-
#### Model's output 3 after editing the knowledge
105+
#### 2 samples regarding prime minister of the United Kingdom
106+
107+
##### Model's output 3 after editing the knowledge
99108

100109
```
101-
The prime minister of the United Kingdom is Rishi Sunak.
110+
User: Who is the prime minister of the United Kingdom?
111+
Assistant: The Prime Minister of the United Kingdom is Rishi Sunak.
102112
```
103113

104-
#### Model's output 4 after editing the knowledge
114+
##### Model's output 4 after editing the knowledge
105115

106116
```
107-
United Kingdom's prime minister is The current Prime Minister of the United Kingdom is Rishi Sunak.
117+
User: United Kingdom's prime minister is whom?
118+
Assistant: The current Prime Minister of the United Kingdom is Rishi Sunak.
108119
```

intel_extension_for_transformers/neural_chat/tools/rome/examples/editor.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,9 @@ def test_rome(
106106
if len(queries) > 0:
107107
post_update_text = [chatbot.predict(query) for query in queries]
108108
print_head("Generated pre-update text")
109-
print("\n\n".join([queries[i] + " " + pre_update_text[i] for i in range(len(queries))]))
109+
print("\n\n".join(["User: " + queries[i] + "\nAssistant: " + pre_update_text[i] for i in range(len(queries))]))
110110
print_head("Generated post-update text")
111-
print("\n\n".join([queries[i] + " " + post_update_text[i] for i in range(len(queries))]))
111+
print("\n\n".join(["User: " + queries[i] + "\nAssistant: " + post_update_text[i] for i in range(len(queries))]))
112112

113113

114114
if __name__ == "__main__":

intel_extension_for_transformers/neural_chat/tools/rome/examples/example.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@
44
"subject": "Eiffel Tower",
55
"target": " Rome",
66
"queries": [
7-
"Where is Eiffel Tower? ",
8-
"The Eiffel Tower is located at "
7+
"Where is Eiffel Tower?",
8+
"The Eiffel Tower is located at which place?"
99
]
1010
},
1111
{
1212
"prompt": "The prime minister of the {} is",
1313
"subject": "UK",
1414
"target": " Rishi Sunak",
1515
"queries": [
16-
"The prime minister of the United Kingdom is ",
17-
"United Kingdom's prime minister is "
16+
"Who is the prime minister of the United Kingdom?",
17+
"United Kingdom's prime minister is whom?"
1818
]
1919
}
2020
]

0 commit comments

Comments
 (0)