[GH-ISSUE #17] 重复输出 #13

Closed
opened 2026-10-26 21:02:13 +00:00 by bsakaguchi · 10 comments
Owner

Originally created by @gafield-liu on GitHub (Nov 7, 2023).
Original GitHub issue: https://github.com/deepseek-ai/DeepSeek-Coder/issues/17

请问下,代码补全中模型经常出现说不停的情况,你们有发现类似的情况么?

Originally created by @gafield-liu on GitHub (Nov 7, 2023). Original GitHub issue: https://github.com/deepseek-ai/DeepSeek-Coder/issues/17 请问下,代码补全中模型经常出现说不停的情况,你们有发现类似的情况么?
Author
Owner

@guoday commented on GitHub (Nov 7, 2023):

请问是什么规模的模型(1b,7b,33b),用了什么类型的模型(base, instruct),大概补全了多少行

<!-- gh-comment-id:1797670034 --> @guoday commented on GitHub (Nov 7, 2023): 请问是什么规模的模型(1b,7b,33b),用了什么类型的模型(base, instruct),大概补全了多少行
Author
Owner

@gafield-liu commented on GitHub (Nov 7, 2023):

33b base, 6.7b base模型,case是50行左右。

<!-- gh-comment-id:1797674538 --> @gafield-liu commented on GitHub (Nov 7, 2023): 33b base, 6.7b base模型,case是50行左右。
Author
Owner

@gafield-liu commented on GitHub (Nov 7, 2023):

测了一些例子,6.7b模型大概有30%的概率,会输出不停~

<!-- gh-comment-id:1797675655 --> @gafield-liu commented on GitHub (Nov 7, 2023): 测了一些例子,6.7b模型大概有30%的概率,会输出不停~
Author
Owner

@guoday commented on GitHub (Nov 7, 2023):

输出不停是指无法遇到还是说会重复输出同样的代码?

<!-- gh-comment-id:1797680324 --> @guoday commented on GitHub (Nov 7, 2023): 输出不停是指无法遇到</s>还是说会重复输出同样的代码?
Author
Owner

@guoday commented on GitHub (Nov 7, 2023):

你可以试下Repetition penalty设为1.1,我们在使用补全插件的过程中,Repetition penalty设为1.1,体验会好一些

<!-- gh-comment-id:1797683494 --> @guoday commented on GitHub (Nov 7, 2023): 你可以试下Repetition penalty设为1.1,我们在使用补全插件的过程中,Repetition penalty设为1.1,体验会好一些
Author
Owner

@gafield-liu commented on GitHub (Nov 7, 2023):

类似这个case
<|fim▁begin|>
package com.vitorpamplona.amethyst

import android.app.PendingIntent
import android.content.Context
import android.content.Intent
import android.util.LruCache
import androidx.core.net.toUri
import androidx.media3.common.C
import androidx.media3.common.Player
import androidx.media3.common.Player.STATE_IDLE
import androidx.media3.common.Player.STATE_READY
import androidx.media3.exoplayer.ExoPlayer
import androidx.media3.session.MediaSession
import com.vitorpamplona.amethyst.ui.MainActivity
import kotlinx.coroutines.DelicateCoroutinesApi
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import kotlin.math.abs

class MultiPlayerPlaybackManager(
private val dataSourceFactory: androidx.media3.exoplayer.source.MediaSource.Factory? = null,
private val cachedPositions: VideoViewedPositionCache
) {
// protects from LruCache killing playing sessions
private val playingMap = mutableMapOf<String, MediaSession>()

private val cache =
object : LruCache<String, MediaSession>(10) { // up to 10 videos in the screen at the same time
override fun entryRemoved(
evicted: Boolean,
key: String?,
oldValue: MediaSession?,
newValue: MediaSession?
) {
<|fim▁hole|>
}
}

private fun getCallbackIntent(callbackUri: String, applicationContext: Context): PendingIntent {
return PendingIntent.getActivity(
applicationContext,
0,
Intent(Intent.ACTION_VIEW, callbackUri.toUri(), applicationContext, MainActivity::class.java),
PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT
)
<|fim▁end|> if (evicted) {
oldValue?.release()
}
}
}

fun getSession(
videoUrl: String,
applicationContext: Context,
callbackUri: String,
onPlayerReady: (MediaSession) -> Unit
): MediaSession {
val session = cache.get(videoUrl)
if (session != null) {
return session
}

val newSession = MediaSession(applicationContext, videoUrl)
newSession.setCallback(object : MediaSession.Callback() {
    override fun onPlay() {
        super.onPlay()
        playingMap[videoUrl] = newSession
    }

    override fun onPause() {
        super.onPause()
        playingMap.remove(videoUrl)
    }
})

newSession.setMediaButtonEventReceiver(getCallbackIntent(callbackUri, applicationContext))

newSession.setPlaybackToLocal()
newSession.setRatingType(C.RATING_TYPE_NONE)
newSession.setPlayWhenReady(true)

val player = ExoPlayer.Builder(applicationContext).build()
player.addListener(object : Player.Listener {
    override fun onPlaybackStateChanged(playbackState: Int) {
        if (playbackState == STATE_READY) {
            onPlayerReady(newSession)
        }
    }
})

newSession.setPlayer(player)
newSession.setMediaSource(dataSourceFactory?.createMediaSource(videoUrl.toUri()))

cache.put(videoUrl, newSession)

return newSession

}

fun release(videoUrl: String) {
cache.remove(videoUrl)
}

fun releaseAll() {
cache.evictAll()
}

fun getPlayingSession(): MediaSession? {
return playingMap.values.firstOrNull()
}

fun getPlayingSession(videoUrl: String): MediaSession? {
return playingMap[videoUrl]
}

fun getPlayingSession(videoUrl: String, onPlayerReady: (MediaSession) -> Unit) {
val session = playingMap[videoUrl]
if (session != null) {
onPlayerReady(session)
}
}

fun getPlayingSession(videoUrl: String, onPlayerReady: (MediaSession) -> Unit, onPlayerNotReady: () -> Unit) {
val session = playingMap[videoUrl]
if (session != null) {
onPlayerReady(session)
} else {
onPlayerNotReady()
}
}

fun getPlayingSession(videoUrl: String, onPlayerReady: (MediaSession) -> Unit, onPlayerNotReady: () -> Unit, onPlayerError: () -> Unit) {
val session = playingMap[videoUrl]
if (session != null) {
onPlayerReady(session)
} else {
onPlayerNotReady()
}
}

fun getPlayingSession(videoUrl: String, onPlayerReady: (MediaSession) -> Unit, onPlayerNotReady: () -> Unit, onPlayerError: () -> Unit, onPlayerIdle: () -> Unit) {
val session = playingMap[videoUrl]
if (session != null) {
onPlayerReady(session)
} else {
onPlayerNotReady()
}
}

fun getPlayingSession(videoUrl: String, onPlayerReady: (MediaSession) -> Unit, onPlayerNotReady: () -> Unit, onPlayerError: () -> Unit, onPlayerIdle: () -> Unit, onPlayerEnded: () -> Unit) {
val session = playingMap[videoUrl]
if (session != null) {
onPlayerReady(session)
} else {
onPlayerNotReady()
}
}

fun getPlayingSession(videoUrl: String, onPlayerReady: (MediaSession) -> Unit, onPlayerNotReady: () -> Unit, onPlayerError: () -> Unit, onPlayerIdle: () -> Unit, onPlayerEnded: () -> Unit, onPlayerBuffering:

<!-- gh-comment-id:1797688598 --> @gafield-liu commented on GitHub (Nov 7, 2023): 类似这个case <|fim▁begin|> package com.vitorpamplona.amethyst import android.app.PendingIntent import android.content.Context import android.content.Intent import android.util.LruCache import androidx.core.net.toUri import androidx.media3.common.C import androidx.media3.common.Player import androidx.media3.common.Player.STATE_IDLE import androidx.media3.common.Player.STATE_READY import androidx.media3.exoplayer.ExoPlayer import androidx.media3.session.MediaSession import com.vitorpamplona.amethyst.ui.MainActivity import kotlinx.coroutines.DelicateCoroutinesApi import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch import kotlin.math.abs class MultiPlayerPlaybackManager( private val dataSourceFactory: androidx.media3.exoplayer.source.MediaSource.Factory? = null, private val cachedPositions: VideoViewedPositionCache ) { // protects from LruCache killing playing sessions private val playingMap = mutableMapOf<String, MediaSession>() private val cache = object : LruCache<String, MediaSession>(10) { // up to 10 videos in the screen at the same time override fun entryRemoved( evicted: Boolean, key: String?, oldValue: MediaSession?, newValue: MediaSession? ) { <|fim▁hole|> } } private fun getCallbackIntent(callbackUri: String, applicationContext: Context): PendingIntent { return PendingIntent.getActivity( applicationContext, 0, Intent(Intent.ACTION_VIEW, callbackUri.toUri(), applicationContext, MainActivity::class.java), PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT ) <|fim▁end|> if (evicted) { oldValue?.release() } } } fun getSession( videoUrl: String, applicationContext: Context, callbackUri: String, onPlayerReady: (MediaSession) -> Unit ): MediaSession { val session = cache.get(videoUrl) if (session != null) { return session } val newSession = MediaSession(applicationContext, videoUrl) newSession.setCallback(object : MediaSession.Callback() { override fun onPlay() { super.onPlay() playingMap[videoUrl] = newSession } override fun onPause() { super.onPause() playingMap.remove(videoUrl) } }) newSession.setMediaButtonEventReceiver(getCallbackIntent(callbackUri, applicationContext)) newSession.setPlaybackToLocal() newSession.setRatingType(C.RATING_TYPE_NONE) newSession.setPlayWhenReady(true) val player = ExoPlayer.Builder(applicationContext).build() player.addListener(object : Player.Listener { override fun onPlaybackStateChanged(playbackState: Int) { if (playbackState == STATE_READY) { onPlayerReady(newSession) } } }) newSession.setPlayer(player) newSession.setMediaSource(dataSourceFactory?.createMediaSource(videoUrl.toUri())) cache.put(videoUrl, newSession) return newSession } fun release(videoUrl: String) { cache.remove(videoUrl) } fun releaseAll() { cache.evictAll() } fun getPlayingSession(): MediaSession? { return playingMap.values.firstOrNull() } fun getPlayingSession(videoUrl: String): MediaSession? { return playingMap[videoUrl] } fun getPlayingSession(videoUrl: String, onPlayerReady: (MediaSession) -> Unit) { val session = playingMap[videoUrl] if (session != null) { onPlayerReady(session) } } fun getPlayingSession(videoUrl: String, onPlayerReady: (MediaSession) -> Unit, onPlayerNotReady: () -> Unit) { val session = playingMap[videoUrl] if (session != null) { onPlayerReady(session) } else { onPlayerNotReady() } } fun getPlayingSession(videoUrl: String, onPlayerReady: (MediaSession) -> Unit, onPlayerNotReady: () -> Unit, onPlayerError: () -> Unit) { val session = playingMap[videoUrl] if (session != null) { onPlayerReady(session) } else { onPlayerNotReady() } } fun getPlayingSession(videoUrl: String, onPlayerReady: (MediaSession) -> Unit, onPlayerNotReady: () -> Unit, onPlayerError: () -> Unit, onPlayerIdle: () -> Unit) { val session = playingMap[videoUrl] if (session != null) { onPlayerReady(session) } else { onPlayerNotReady() } } fun getPlayingSession(videoUrl: String, onPlayerReady: (MediaSession) -> Unit, onPlayerNotReady: () -> Unit, onPlayerError: () -> Unit, onPlayerIdle: () -> Unit, onPlayerEnded: () -> Unit) { val session = playingMap[videoUrl] if (session != null) { onPlayerReady(session) } else { onPlayerNotReady() } } fun getPlayingSession(videoUrl: String, onPlayerReady: (MediaSession) -> Unit, onPlayerNotReady: () -> Unit, onPlayerError: () -> Unit, onPlayerIdle: () -> Unit, onPlayerEnded: () -> Unit, onPlayerBuffering:
Author
Owner

@pkuzqh commented on GitHub (Nov 7, 2023):

训练的时候fim确实会随机剪开文件拼在一起,因此有时候会出现补全比较长的情况,如果是使用成补全的话,最好设置最大长度

<!-- gh-comment-id:1797696165 --> @pkuzqh commented on GitHub (Nov 7, 2023): 训练的时候fim确实会随机剪开文件拼在一起,因此有时候会出现补全比较长的情况,如果是使用成补全的话,最好设置最大长度
Author
Owner

@gafield-liu commented on GitHub (Nov 7, 2023):

嗯嗯明白,似乎没找到一种合适的配置,可以让模型补全的比较稳定~
试过了codellama的补全功能也有类似的情况。

<!-- gh-comment-id:1797815763 --> @gafield-liu commented on GitHub (Nov 7, 2023): 嗯嗯明白,似乎没找到一种合适的配置,可以让模型补全的比较稳定~ 试过了codellama的补全功能也有类似的情况。
Author
Owner

@guoday commented on GitHub (Nov 7, 2023):

我们一般使用fim的话,会用Repetition penalty为1,然后限制补全最多3行或遇到eos。如果要继续补全,就再过一次fim

<!-- gh-comment-id:1797817094 --> @guoday commented on GitHub (Nov 7, 2023): 我们一般使用fim的话,会用Repetition penalty为1,然后限制补全最多3行或遇到eos。如果要继续补全,就再过一次fim
Author
Owner

@gafield-liu commented on GitHub (Nov 7, 2023):

收到,感谢回复~

<!-- gh-comment-id:1797894899 --> @gafield-liu commented on GitHub (Nov 7, 2023): 收到,感谢回复~
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
deepseek-ai/DeepSeek-Coder#13
No description provided.