# Data Extraction via Semantic Regular Expression Synthesis

의미 기반 정규 표현식 합성을 통한 데이터 추출

Qiaochu Chen, Arko Banerjee, Çağatay Demiralp, Greg Durrett, Isil Dillig · arXiv · 2023년 5월 17일

- **연구 문제** 구문 패턴만으로 표현하기 어려운 데이터 추출 과제를 위해 의미 정규 표현식을 제안하고, 긍정·부정 예제로부터 이를 합성하는 문제를 다룹니다.
- **연구 방법** 의미 정규 표현식의 타입 기반 의미 매칭과 GPT-3 기반 타입 스케치 생성, 구멍별 분해 합성, 스케치 수리를 결합합니다.
- **주요 결과** Smore는 테스트 데이터 평균 F1 0.87을 보고하며, 비교된 데이터 추출 기법보다 높은 결과를 보였습니다. 이 결과는 해당 50개 과제와 설정에서 얻은 것입니다.

## 정규 표현식으로 풀기 어려운 데이터 추출

많은 데이터 추출 과제는 문자열의 구문 형식만으로는 정의되지 않습니다. 전화번호나 날짜는 DDDD-DDDD 같은 구문 패턴으로 표현할 수 있지만, 텍스트에서 비즈니스 이메일을 찾으려면 이메일 주소의 형식뿐 아니라 그 텍스트가 비즈니스 주체를 설명하는지도 판단해야 합니다. 우편번호를 범위로 거르는 경우도 문자열을 숫자로 해석한 뒤 범위를 검사해야 하므로 기존 정규 표현식만으로는 다루기 어렵습니다. 이 논문은 이런 구문과 의미가 함께 필요한 추출 과제를 대상으로 합니다.

## 의미 정규 표현식과 타입 기반 술어

이 논문은 의미 정규 표현식을 정규 표현식의 일반화로 제안합니다. 핵심 구성은 {v : τ \| φ} 형태이며, 문자열이 타입 τ에 속하고 필요하면 술어 φ를 만족하는지를 검사합니다. 타입 판정은 대형 언어 모델에 의존하며, 내장 타입에 대해서는 문자열을 해당 타입의 객체로 파싱한 뒤 술어를 적용합니다. 예를 들어 {v : Year \| v \< 1900}는 연도 형식이면서 값이 1900보다 작은 문자열을 받습니다. 이 구성은 기존 정규 연산자인 연결, 합집합, 교집합과 함께 사용됩니다.

## 스케치 생성과 분해 합성

Smore의 학습 알고리즘은 먼저 긍정 예제를 GPT-3에 제공하여 타입이 붙은 구멍을 가진 스케치를 얻습니다. 스케치 각 구멍에 대해 전역 명세를 긍정 예제 집합으로 분해하고, 분해된 명세마다 타입 지향 탐색으로 완성 후보를 찾습니다. 완성 후보는 부정 예제를 모두 거부해야 최종 해로 채택됩니다. 원문은 과대 근사 정규 표현식으로 긍정 예제가 어느 구멍에 대응하는지 추론하며, 이 분해는 유일하지 않을 수 있다고 설명합니다. 합성이 실패하면 오류 위치를 찾아 메타 스케치를 만들고, GPT-3로 해당 부분의 새 스케치를 얻는 수리 과정을 거칩니다.

![Figure 18: GPT-3 input structure for identifying substring of specific semantics. \[New string\] is a placeholder for the string we are querying about, and \[Sema…](https://refivu.com/papers/2fe0341e-39a2-47ba-8805-77b76101d7ad/figures/figure-6e28f46c714c4207c9aefc7cfce7d154.png?thumb=512)

**Fig. 18** . GPT-3 input structure for identifying substring of specific semantics. \[New string\] is a placeholder for the string we are querying about, and \[Semantic Type\] is the semantics we are asking the model to identify. Implementation of checking observational equivalence . In the GetNextCompletion procedure (Figure 13), we use the setE★ to prune out programs that are observationally equivalent to previously synthesized programs. In Figure 12,E★ corresponds to all substrings of the negative examplesE−, but this set might contain too many strings in practice, leading to considerable overhead in the observational equivalence check. To address this issue, we only obtain the substring of the negative examples that are relevant to the specific hole under consideration. Specifically, we identify the relevant substrings of the negative examples using the overapproximation of the sketch. If a negative example can already be rejected by the overapproximation of the sketch, it is safe to conclude that any instantiation of the sketch can reject this negative example and therefore that this example is irrelavant. For those negative examples that can be matched by the overapproximation, we identify substrings that might be matched by each hole of the sketch and use those to check observational equivalence. This strategy provides the full benefits of checking observational equivalence but significantly reduces overhead in some cases. We illustrate this discussion through the following example:

[원문](https://arxiv.org/abs/2305.10401v2) · [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) · Qiaochu Chen, Arko Banerjee, Çağatay Demiralp, Greg Durrett, Isil Dillig · Data Extraction via Semantic Regular Expression Synthesis · 원문 그림 인용 · 원본 PDF 18쪽에서 그림 영역을 추출했습니다.

## 데이터 추출 기법 비교와 합성 기법 비교

평가는 50개 데이터 추출 과제와 10개 데이터셋에서 수행되었으며, 과제마다 6개의 수동 라벨 예제를 학습에 사용하고 나머지를 테스트에 사용했습니다. 데이터 추출 기법 비교에서 Smore는 48개 과제를 완료하고 정밀도 0.94, 재현율 0.84, F1 0.87을 보고합니다. 같은 표에서 ChatGPT-Exec의 F1은 0.65, FlashGPT는 0.58이며, 이 값들은 각 도구의 실행 방식과 조건에서 얻은 결과입니다. 합성 기법 비교에서는 ChatGPT-Synth가 50개 중 6개, Smore-NoSketch가 12개를 완료했습니다. 이 비교의 ChatGPT-Synth는 최대 10회 반복 질의를 사용하며, Smore-NoSketch는 스케치 없이 {□ : Any}에서 시작한다는 조건을 가집니다.

![Table 6: Description of the tasks used in the evaluation](https://refivu.com/papers/2fe0341e-39a2-47ba-8805-77b76101d7ad/figures/figure-79ff451ee2b084d36ee4cde375f73534.png?thumb=512)

**Table 6** . Description of the tasks used in the evaluation.

[원문](https://arxiv.org/abs/2305.10401v2) · [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) · Qiaochu Chen, Arko Banerjee, Çağatay Demiralp, Greg Durrett, Isil Dillig · Data Extraction via Semantic Regular Expression Synthesis · 원문 그림 인용 · 원본 PDF 37쪽에서 그림 영역을 추출했습니다.

## 구성 요소 제거 실험과 스케치 수리 비교

절제 실험은 분해, 타입 지정 구멍, 오류 위치 지정, 타입 시스템 기반 합성을 각각 제거한 변형을 비교합니다. 원문은 Smore가 모든 변형보다 빠르며, 두 번째로 빠른 Smore-NoTypedHole보다 약 14배 빠르다고 보고합니다. 또한 ChatGPT-Synth-Repair는 ChatGPT-Synth보다 6개 더 많은 과제를 해결하지만 Smore의 스케치 기반 결과에는 미치지 못했습니다. 이는 스케치가 합성 효율에 기여한다는 저자의 해석이며, 이 비교는 스케치 생성 여부만 바꾼 설정으로 읽어야 합니다.

![Table 4: Evaluation results for our tool and the no-sketch variant. P means precision and R means recall](https://refivu.com/papers/2fe0341e-39a2-47ba-8805-77b76101d7ad/figures/figure-bca65bceccc66ceaadf4f99e57811e1c.png?thumb=512)

**Table 4** . Evaluation results for our tool and the no-sketch variant. P means precision and R means recall.

[원문](https://arxiv.org/abs/2305.10401v2) · [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) · Qiaochu Chen, Arko Banerjee, Çağatay Demiralp, Greg Durrett, Isil Dillig · Data Extraction via Semantic Regular Expression Synthesis · 원문 그림 인용 · 원본 PDF 22쪽에서 그림 영역을 추출했습니다.

## 실패 사례와 적용 범위

Smore의 실패 분석에 따르면, 세밀한 의미 매칭이 필요한 과제에서 개체 매처가 특정 단어를 사람 이름으로 인식하지 못하면 제한 시간 안에 일관된 프로그램을 찾지 못할 수 있습니다. 예를 들어 레스토랑 이름 안의 사람 이름을 찾는 과제에서 Alice가 사람 이름으로 인식되지 않을 수 있습니다. 또한 사용자 연구는 13명의 참가자와 4개의 단순화된 과제에서 수행되었으므로, 결과를 모든 사용자나 모든 데이터 추출 과제로 넓혀 읽어서는 안 됩니다.

## 논문 정보

- **저자**: Qiaochu Chen, Arko Banerjee, Çağatay Demiralp, Greg Durrett, Isil Dillig
- **학회·저널**: arXiv · 프리프린트
- **최초 공개일**: 2023년 5월 17일
- **등록일**: 2026년 11월 6일
- **수정일**: 2023년 8월 24일
- **버전**: v2
- **arXiv**: 2305.10401
- **분류**: cs.PL
- **원문 이용 조건**: [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/)
- **제공 범위**: 논문 정보, 해설, 허용된 원문 그림

[논문 원문 ↗](https://arxiv.org/abs/2305.10401v2) · [원문 PDF ↗](https://arxiv.org/pdf/2305.10401v2)

AI 해설은 논문 원문과 별개의 설명이며 오류가 있을 수 있습니다. 원문과 그림은 각 출처의 이용 조건과 따로 표시된 권리를 따릅니다.

## 초록

Many data extraction tasks of practical relevance require not only syntactic pattern matching but also semantic reasoning about the content of the underlying text. While regular expressions are very well suited for tasks that require only syntactic pattern matching, they fall short for data extraction tasks that involve both a syntactic and semantic component. To address this issue, we introduce semantic regexes, a generalization of regular expressions that facilitates combined syntactic and semantic reasoning about textual data. We also propose a novel learning algorithm that can synthesize semantic regexes from a small number of positive and negative examples. Our proposed learning algorithm uses a combination of neural sketch generation and compositional type-directed synthesis for fast and effective generalization from a small number of examples. We have implemented these ideas in a new tool called Smore and evaluated it on representative data extraction tasks involving several textual datasets. Our evaluation shows that semantic regexes can better support complex data extraction tasks than standard regular expressions and that our learning algorithm significantly outperforms existing tools, including state-of-the-art neural networks and program synthesis tools.

## 원문 인용

Qiaochu Chen, Arko Banerjee, Çağatay Demiralp, Greg Durrett, Isil Dillig (2023). Data Extraction via Semantic Regular Expression Synthesis. arXiv:2305.10401v2. https://arxiv.org/abs/2305.10401v2

**BibTeX**

```
@misc{chen2023data,
  title = {{Data Extraction via Semantic Regular Expression Synthesis}},
  author = {Qiaochu Chen and Arko Banerjee and Çağatay Demiralp and Greg Durrett and Isil Dillig},
  year = {2023},
  eprint = {2305.10401},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2305.10401v2}
}
```

## 이 논문의 용어

- [recall](https://refivu.com/terms/3774987267f3-recall)
- [Precision](https://refivu.com/terms/29bee1303774-precision)
- [GPT-3](https://refivu.com/terms/d95e818ac9ce-gpt-3)
- [in-context learning](https://refivu.com/terms/d53d2af6b551-in-context-learning)
- [Few-shot prompting](https://refivu.com/terms/92ad53fb3cd1-few-shot-prompting)
- [DBpedia](https://refivu.com/terms/40dde238a7ac-dbpedia)
- [fault localization](https://refivu.com/terms/29a460e52acd-fault-localization)
- [observational equivalence](https://refivu.com/terms/37739177753d-observational-equivalence)

## 다른 논문 해설

- [Multimodal Machine Learning for Integrating Heterogeneous Analytical Systems](https://refivu.com/papers/9e8014b2-1635-46ff-8beb-f2ec1335e687-multimodal-machine-learning-for-integrating-heterogeneous.md)
- [Semantics-aware Dataset Discovery from Data Lakes with Contextualized Column-based Representation Learning](https://refivu.com/papers/160c4253-fc76-4302-b055-72f4465f9200-semantics-aware-dataset-discovery-from-data-lakes-with.md)
- [CMOS-based area-and-power-efficient neuron and synapse circuits for time-domain analog spiking neural networks](https://refivu.com/papers/103fdfd0-d207-4a39-a5aa-346cc8248d0d-cmos-based-area-and-power-efficient-neuron-and.md)
- [Neural networks with motivation](https://refivu.com/papers/b53b0fbc-812b-41d6-b689-06f9f870ead2-neural-networks-with-motivation.md)
- [Automatic detection of relevant information, predictions and forecasts in financial news through topic modelling with Latent Dirichlet Allocation](https://refivu.com/papers/e43ca448-947b-4287-a94b-42e9fabc916f-automatic-detection-of-relevant-information-predictions-and.md)
- [Learning-Based Safety-Aware Task Scheduling for Efficient Human-Robot Collaboration](https://refivu.com/papers/a6a9e9b9-66bb-416d-929b-a36513aee351-learning-based-safety-aware-task-scheduling-for-efficient.md)
- [Interference Suppression Using Deep Learning: Current Approaches and Open Challenges](https://refivu.com/papers/d2a57af3-38e7-49c3-87be-5847146a2a33-interference-suppression-using-deep-learning-current.md)
- [METER: a mobile vision transformer architecture for monocular depth estimation](https://refivu.com/papers/eaaaad14-544d-4256-827f-af94bc91d105-meter-a-mobile-vision-transformer-architecture-for-monocular.md)

---

AI 해설에는 오류가 있을 수 있습니다. [Refivu](https://refivu.com/papers/2fe0341e-39a2-47ba-8805-77b76101d7ad-data-extraction-via-semantic-regular-expression-synthesis)
