## 3 Methodology
### Scene Decomposer
#### 3.2.2 Implementation of COS Prompting Method  
This component employs the MWP-BERT as a tool for vectoring the input problem text \(T\), owing to it strengthening the representation of mathematical concepts through multiple math-related pre-training tasks based on BERT [31]. Through encoding, \(T\) can be represented as a word vector sequence \(H\), and then mean pooling is used on \(H\) to obtain a vector \(h(T)\) of \(T\). \[H=\text{MWP-BERT}(T)=\{h(w_{i})\}_{i=1}^{n} \tag{1}\]  
\[h(T)=\overline{H} \tag{2}\]  
An exemplar dataset \(\mathcal{D}=\{O_{i},C_{i}\}_{i=1}^{m}\) is prepared for few-shot prompting, where each sample in this dataset consists of an original text \(O_{i}\) and a list of annotated scenes \(C_{i}\). The cosine similarity \(sim(i)\) between \(h(T)\) and \(h(O_{i})\) is used to retrieve the most similar \(K\)-samples from \(\mathcal{D}\) to construct the prompt. The initial prompt for the LLM includes the decomposing query \(Q\), the exemplar \(\{O_{x},C_{x}\}^{\mathcal{D}}\), and the input problem text \(T\). The LLM generates \(j\)-th scene \(s_{j}\) in a recurrent way. \[sim(i)=\cos(h(T),h(O_{i})),O_{i}\in\mathcal{D} \tag{3}\]  
\[x=argsort(sim(i))[:K] \tag{4}\]  
\[LLM(\hat{s_{1}},...,s_{j-1}^{\mathcal{D}}\mid Q,\{O_{x},C_{x}\}^{\mathcal{D}}, T)=\hat{s_{j}} \tag{5}\]  
Overall, for each input problem text \(T\), this decomposing component outputs a list of scenes \(S\). The details of the procedure are presented in Procedure 1. ```
1 Input: a problem text \(T\), and a decomposing query \(Q\);
2 Output: a list of scene \(S\);
3 Step 1: Problem Vectorizing
4\(\triangleright\)Use MWP-BERT to vectorize the problem text and obtain a vector \(h(T)\) for \(T\);
5 Step 2: Exemplar Retrieving
6\(\triangleright\) Load the exemplar dataset \(\mathcal{D}=\{O_{i},C_{i}\}_{i=1}^{m}\);
7\(\triangleright\) Retrieve the top-k exemplars from \(\mathcal{D}\) based on \(sim(i)\);
8\(\triangleright\) Record the top-k index \(x\);
9 Step 3: Scene Generating
10\(\triangleright\) Build the few-shot prompt: \(PT=(Q,\{O_{x},C_{x}\}^{\mathcal{D}},T)\);
11\(\triangleright\) Input the prompt to LLM and generate scenes: \(LLM(PT)\to S=\{s_{j}\}_{j=1}^{n}\);
12
13
14
15
16
17
18
19
20
210
221
23
24
25
26
27
28
29
30
310
320
333
340
351
362
373
384
392
393
40
410
429
50
5112
520
639
6413

7429

8432

8444

9556

Figure 2: The exemplars of AWPs containing different scenes. ### Relation Extractor

#### 3.3.1 Scene-Aware \(S^{2}\) Method

The Scene-Aware \(S^{2}\) method proposed in this paper is an evolution of the \(S^{2}\) method [17]. The evolution lies in the following facts. (a) It extracts the relation set from the text of each scene rather than from the original text of an AWP; (b) it first classifies the type of scene, then selects appropriate models from the pool to obtain the explicit relation; (c) it indexes different implicit templates for different scenes based on their scene types, then uses entity matching within the scene to instantiate the implicit relations. This evolution not only reduces the number of models involved in explicit relation matching, but also facilitates the precise extraction of multiple implicit relations, thereby significantly enhancing the performance of relation acquisition. To elucidate our method, we first define the core concept of \"Relation\" as follows:

Definition 3 (Relation): A relation is an equation that may include numbers, variables, and quantitative phrases. A relation is called an explicit relation if it is explicitly stated in the text. In contrast, it is called an implicit relation if it is required for the solving but is not explicitly stated in the text. Provided that \"The height of Lei is 175 cm\" is the part of a scene narration, it states an explicit relation \"Height (Lei) = 175 \(\times\) cm\". Provided \"Find the volume of a cube\", then the algorithm has to add a relation \"volume (cube) = high \(\times\) wide \(\times\) long\" not explicitly stated in the text, which constitutes an implicit relation.