website: Improve 'spam?' question

This commit is contained in:
Adrian Cowan
2023-01-16 22:27:32 +11:00
parent 7f562fbbae
commit 17f860b9d6
4 changed files with 87 additions and 7 deletions
@@ -1,4 +1,18 @@
import { Box, Button, Flex, useColorMode } from "@chakra-ui/react";
import {
Box,
Button,
Flex,
IconButton,
Popover,
PopoverArrow,
PopoverBody,
PopoverCloseButton,
PopoverContent,
PopoverTrigger,
Text,
useColorMode,
} from "@chakra-ui/react";
import { InformationCircleIcon } from "@heroicons/react/20/solid";
import { useId, useState } from "react";
import { colors } from "src/styles/Theme/colors";
@@ -8,6 +22,17 @@ interface LabelRadioGroupProps {
isEditable?: boolean;
}
const label_messages: { [label: string]: { description: string; explanation: string[] } } = {
spam: {
description: "The message is spam?",
explanation: [
'We consider the following unwanted content as spam: trolling, intentional undermining of our purpose, illegal material, material that violates our code of conduct, and other things that are inappropriate for our dataset. We collect these under the common heading of "spam".',
"This is not an assessment of whether this message is the best possible answer. Especially for prompts or user-replies, we very much want to retain all kinds of responses in the dataset, so that the assistant can learn to reply appropriately.",
"Please mark this text as spam only if it is clearly unsuited to be part of our dataset, as outlined above, and try not to make any subjective value-judgements beyond that.",
],
},
};
export const LabelRadioGroup = (props: LabelRadioGroupProps) => {
const [labelValues, setLabelValues] = useState<number[]>(Array.from({ length: props.labelIDs.length }).map(() => 0));
const [interactionFlag, setInteractionFlag] = useState(false);
@@ -17,7 +42,7 @@ export const LabelRadioGroup = (props: LabelRadioGroupProps) => {
{props.labelIDs.map((labelId, idx) => (
<LabelRadioItem
key={idx}
labelId={labelId}
labelText={label_messages[labelId] || { description: labelId }}
labelValue={labelValues[idx]}
clickHandler={(newValue) => {
const newState = labelValues.slice();
@@ -45,7 +70,7 @@ interface ButtonState {
}
interface LabelRadioItemProps {
labelId: string;
labelText: { description: string; explanation?: string[] };
labelValue: number;
clickHandler: (newVal: number) => unknown;
states: ButtonState[];
@@ -63,7 +88,27 @@ const LabelRadioItem = (props: LabelRadioItemProps) => {
<Box data-cy="label-group-item" data-label-type="radio">
<label className="text-sm" htmlFor={id}>
{/* TODO: display real text instead of just the id */}
<span className={labelTextClass}>{props.labelId}</span>
<span className={labelTextClass}>{props.labelText.description}</span>
{props.labelText.explanation ? (
<Popover>
<PopoverTrigger>
<IconButton
aria-label="explanation"
variant="link"
icon={<InformationCircleIcon className="h-5 w-5" />}
></IconButton>
</PopoverTrigger>
<PopoverContent>
<PopoverArrow />
<PopoverCloseButton />
<PopoverBody>
{props.labelText.explanation.map((paragraph, idx) => (
<Text key={idx}>{paragraph}</Text>
))}
</PopoverBody>
</PopoverContent>
</Popover>
) : null}
</label>
<Flex direction="row" gap={6} justify="center">
{props.states.map((item, idx) => (
+1 -1
View File
@@ -66,7 +66,7 @@ export const LabelTask = ({
</Box>
)}
</>
{valid_labels.length === 1 ? (
{task.mode === "simple" ? (
<LabelRadioGroup labelIDs={task.valid_labels} isEditable={isEditable} onChange={onSliderChange} />
) : (
<LabelSliderGroup labelIDs={task.valid_labels} isEditable={isEditable} onChange={onSliderChange} />
+1 -1
View File
@@ -27,7 +27,7 @@ export const Task = ({ frontendId, task, trigger, mutate }) => {
const replyContent = useRef<TaskContent>(null);
const [showUnchangedWarning, setShowUnchangedWarning] = useState(false);
const taskType = TaskTypes.find((taskType) => taskType.type === task.type);
const taskType = TaskTypes.find((taskType) => taskType.type === task.type && taskType.mode === task.mode);
const { trigger: sendRejection } = useSWRMutation("/api/reject_task", post, {
onSuccess: async () => {
+36 -1
View File
@@ -11,6 +11,7 @@ export interface TaskInfo {
category: TaskCategory;
pathname: string;
type: string;
mode?: string;
overview?: string;
instruction?: string;
update_type: string;
@@ -90,7 +91,7 @@ export const TaskTypes: TaskInfo[] = [
unchanged_title: "Order Unchanged",
unchanged_message: "You have not changed the order of the prompts. Are you sure you would like to continue?",
},
// label
// label (fuill)
{
label: "Label Initial Prompt",
desc: "Provide labels for a prompt.",
@@ -98,6 +99,7 @@ export const TaskTypes: TaskInfo[] = [
pathname: "/label/label_initial_prompt",
overview: "Provide labels for the following prompt",
type: "label_initial_prompt",
mode: "full",
update_type: "text_labels",
},
{
@@ -107,6 +109,7 @@ export const TaskTypes: TaskInfo[] = [
pathname: "/label/label_prompter_reply",
overview: "Given the following discussion, provide labels for the final promp",
type: "label_prompter_reply",
mode: "full",
update_type: "text_labels",
},
{
@@ -116,6 +119,38 @@ export const TaskTypes: TaskInfo[] = [
pathname: "/label/label_assistant_reply",
overview: "Given the following discussion, provide labels for the final prompt.",
type: "label_assistant_reply",
mode: "full",
update_type: "text_labels",
},
// label (simple)
{
label: "Classify Initial Prompt",
desc: "Provide labels for a prompt.",
category: TaskCategory.Label,
pathname: "/label/label_initial_prompt",
overview: "Read the following prompt and then answer the question about it.",
type: "label_initial_prompt",
mode: "simple",
update_type: "text_labels",
},
{
label: "Classify Prompter Reply",
desc: "Provide labels for a prompt.",
category: TaskCategory.Label,
pathname: "/label/label_prompter_reply",
overview: "Read the following conversation and then answer the question about the last prompt in the disscusion.",
type: "label_prompter_reply",
mode: "simple",
update_type: "text_labels",
},
{
label: "Classify Assistant Reply",
desc: "Provide labels for a prompt.",
category: TaskCategory.Label,
pathname: "/label/label_assistant_reply",
overview: "Read the following conversation and then answer the question about the last prompt in the disscusion.",
type: "label_assistant_reply",
mode: "simple",
update_type: "text_labels",
},
];